繁体   English   中英

我不知道这段代码是什么

[英]I have no idea what this code is

我一直在四处寻找,我不知道这段代码叫什么。 我从jQuery中提取了它

( function( global, factory ) {

"use strict";

if ( typeof module === "object" && typeof module.exports === "object" ) {

    // For CommonJS and CommonJS-like environments where a proper `window`
    // is present, execute the factory and get jQuery.
    // For environments that do not have a `window` with a `document`
    // (such as Node.js), expose a factory as module.exports.
    // This accentuates the need for the creation of a real `window`.
    // e.g. var jQuery = require("jquery")(window);
    // See ticket #14549 for more info.
    module.exports = global.document ?
        factory( global, true ) :
        function( w ) {
            if ( !w.document ) {
                throw new Error( "jQuery requires a window with a document" );
            }
            return factory( w );
        };
} else {
    factory( global );
}

// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {...})

谁能帮我吗?

可以称为包装/自调用函数。 但实际上,它与功能没有什么不同。 只是在定义时调用的一个不起眼的函数-没有名称。 因此,为什么在声明的末尾直接传递了一个参数列表。

如果您在询问可能看起来很奇怪的代码语法,这就是所谓的“自调用函数”。

这是一个立即调用的函数,未声明其名称。 只是调用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM