Does function placement affect closure performance within scope? If so, where is the optimal place to place these functions? If not, is the implied association of a closure reason enough to place the function elsewhere logically?
For example, if foo does not rely on the value of localState , whether localState is available from foo has consequences for foo runtime, memory usage, etc.
(function(){
var localState;
function foo(){
}
function bar(){
return localState;
}
})();
In other words, would that be the best choice, and if so, why?
(function(){
function foo(){
}
var localState;
function bar(){
return localState;
}
})();
Darius Bacon , , localState . , foo , . ?
function foo(){
}
(function(){
var localState;
function bar(){
foo();
return localState;
}
})();