Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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