Created
September 2, 2009 01:51
-
-
Save kangax/179491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first alert(1), then alert(2) | |
var foo = 1; | |
alert(1); | |
var bar = (function(){ alert(2); })(); | |
// first alert(2), then alert(1) | |
var foo=1,bar=(function(){alert(2);})();alert(1); | |
/* | |
and if we preserve execution of expressions, then there doesn't seem to be any benefit in var hoisting | |
*/ | |
var foo,bar;foo=1;alert(1);bar=(function(){alert(2);})(); | |
// compare with a *shorter* original version: | |
var foo=1;alert(1);var bar=(function(){alert(2);})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment