Skip to content

Instantly share code, notes, and snippets.

@zhannes
Created November 30, 2012 16:53
Show Gist options
  • Save zhannes/4176940 to your computer and use it in GitHub Desktop.
Save zhannes/4176940 to your computer and use it in GitHub Desktop.
javascript scoping - 2
/* #########################
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