Created
November 30, 2012 16:53
-
-
Save zhannes/4176940 to your computer and use it in GitHub Desktop.
javascript scoping - 2
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
/* ######################### | |
2 - SCOPE - CLOSURES | |
hide from global by using a closure | |
*/ | |
(function(n){ // param | |
var myURL = 'google.com'; | |
_log( n === 4 ) // true | |
function b2(){ | |
var c = 'foo'; | |
} | |
})(4); // argument | |
_log( window.myURL ) // undefined | |
_log( window.b2 ) // undefined | |
_log( window.c ) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment