Skip to content

Instantly share code, notes, and snippets.

@sean-roberts
Created June 20, 2013 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sean-roberts/5820178 to your computer and use it in GitHub Desktop.
Save sean-roberts/5820178 to your computer and use it in GitHub Desktop.
Nested Function's Scope : An interesting thing to note about nested functions in javascript is that they have access to the parent functions variables and parameters. This is unlike variables defined at the global level
foo(1);
function foo(a){
var b = 2;
bar(3);
function bar(c){
//all parent variables are visible and editable from here
console.log(a);
console.log(b);
console.log(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment