Skip to content

Instantly share code, notes, and snippets.

@easierbycode
Created March 1, 2012 22:20
Show Gist options
  • Save easierbycode/1953645 to your computer and use it in GitHub Desktop.
Save easierbycode/1953645 to your computer and use it in GitHub Desktop.
auto global
// It?s treated like: var x = (y = 1); thus, ?y=1? creates an auto-global since there?s no binding ?var? statement for it. then that value gets copied into properly defined local var ?x?.
(function(){
var x = y = 1;
})();
alert(x); // undefined
alert(y); // 1 -- oops, auto-global!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment