簡體   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