Created
May 1, 2015 01:29
-
-
Save hillscottc/13adce9430b0e6e3b389 to your computer and use it in GitHub Desktop.
Keep stuff out of global by creating and calling an anon func.
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
/* Keep stuff out of global by creating and calling an anon func. | |
*/ | |
(function() { | |
function square(x) { return x * x; } | |
var hundred = 100; | |
console.log(square(hundred)); | |
})(); | |
// → 10000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment