可能重复:
Are “(function ( ) { } ) ( )” and “(function ( ) { } ( ) )” functionally equal in 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 || {});