, , , ( squidginess , eval, eval, squidginess), 'd , :
(function() {
"use strict";
function foo() {
}
function bar() {
}
})();
, foo bar. , , "" ( ):
(function() {
function foo() {
someNameThatIsntDefined = 42;
}
foo();
})();
... ReferenceError ( - "use strict"):
(function() {
"use strict";
function foo() {
someNameThatIsntDefined = 42;
}
foo();
})();
... , , - .
, , :
var MyModule;
MyModule = MyModule || {};
(function(mod) {
"use strict";
mod.doSomethingUseful = doSomethingUseful;
function doSomethingUseful() {
}
})(MyModule);
"" MyModule.doSomethingUseful, . , , , , . , .