简体   繁体   English

我不知道这段代码是什么

[英]I have no idea what this code is

I have been looking and looking and looking everywhere and I have no idea what this piece of code is called. 我一直在四处寻找,我不知道这段代码叫什么。 I pulled it from jQuery 我从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 ) {...})

Can anyone help me out? 谁能帮我吗?

Could be known as a wrapped/ self invoked function. 可以称为包装/自调用函数。 But really its no different to a function. 但实际上,它与功能没有什么不同。 Just a humble function that gets called on definition - without a name. 只是在定义时调用的一个不起眼的函数-没有名称。 Hence why, at the end of the declaration, there is a list of arguments being passed straight through. 因此,为什么在声明的末尾直接传递了一个参数列表。

If you're asking about the syntax of the code which might look weird to you, this is what called a 'self invoked function'. 如果您在询问可能看起来很奇怪的代码语法,这就是所谓的“自调用函数”。

Which is a function that is being invoked right away, not declaring its's name. 这是一个立即调用的函数,未声明其名称。 just invoking it. 只是调用它。

暂无
暂无

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

相关问题 此 chrome 扩展代码不起作用,我不知道 - This code for a chrome extension is not working, and I have no Idea 我不知道为什么 ng-repeat 在我的代码中不起作用 - I have no idea why ng-repeat is not working in my code Javascript 分配有问题:数组和 object 迭代但我不知道解决方案是什么,我已经尝试了一切 - Having a problem with a Javascript assignment: Array and object iteration but I have no idea what the solution is, I have tried everything Javascript 分配有问题,我不知道解决方案是什么,我已经尝试了一切 - Having a problem with a Javascript assignment and I have no idea what the solution is, i have tried everything 我不知道Object(this)的意思 - I have no idea Object(this) means 我不知道:x 未定义 - I have no idea: x is undefined 我想在提示中按下 Esc 按钮时提醒一个值,但我不知道...(下面的代码) - I want to alert a value when I press the Esc button in prompt, but I have no idea... (code below) 尝试修复Java Countdown。 我不知道我在做什么 - Trying to fix a Javascript Countdown. I have no idea what I'm doing 我正在学习更多JavaScript,我想对这段代码有所了解 - I'm learning more of JavaScript and I want to have some idea about this code 您是否知道为什么我的代码无法正常工作,而单击时却无法获取数字? - Do you have any idea why my code does not work and I can not get the numbers while clicking
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM