Created
June 1, 2014 04:23
-
-
Save 0x4a/244105bc62de7de9e1e7 to your computer and use it in GitHub Desktop.
scoping function for pseudo-global variables - #js
This file contains hidden or 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
(function() { | |
var a = 0; // `a` is NOT a property of `window` now | |
function foo() { | |
alert(a); // Alerts "0", because `foo` can access `a` | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment