var module = {};
(function(exports){
exports.notGlobalFunction = function() {
console.log('I am not global');
};
}(module));
function notGlobalFunction() {
console.log('I am global');
}
notGlobalFunction(); //outputs "I am global"
module.notGlobalFunction(); //outputs "I am not global"
Run Code Online (Sandbox Code Playgroud)
谁能帮我理解这里发生了什么?如果你打电话notGlobalFunction(),我会得到它,它只会调用第二个函数.
但是在var module = {}做什么?为什么在第一个函数内再次调用?
它说这通常被称为自动执行的匿名函数,但我不知道这意味着什么.