I came across a strange behavior related to immediately-invoked function expressions.
var foo = function(){
alert('foo');
}
(function(){
})();
Run the above code and notice how the foo function is evaluated, but..
var foo = function(){
alert('foo');
};
(function(){
})();
http://jsfiddle.net/fwcst8w6/1/
Add a terminator to the function and it is no longer invoked.
I expected that the IIFE would only evaluate the code inside its own function body. Why does the IIFE cause the non-terminated function directly above it to be evaluated?
Even stranger, it only seems to be the function directly above it; run this Fiddle and note how only bar() is evaluated.