Created
June 20, 2013 03:48
-
-
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
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
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