可能重复:
“(function ( ) { } ) ( )” 和 “(function ( ) { } ( ) )” 在 JavaScript 中的功能是否相同?
这两者有区别吗?
(function () {}());
和
(function () {})();
对于在全局范围内构建对象,您对此有何看法:
;(function () {
'use strict';
this.menu = (function () {
var version = "1.2.111",
someFunction = function() {
console.log("Version: " + version);
return version;
};
return {
getVersion: someFunction
};
})();
this.someObject = (function () {
var privateVar = "1234",
privateFunction = function () {
console.log("Private Variable: " + privateVar);
return privateVar;
};
return {
publicFunction: privateFunction
};
})();
}).apply(window.saif = window.saif || {});