Created
April 27, 2012 13:25
-
-
Save ryanhanwu/2509189 to your computer and use it in GitHub Desktop.
JavaScript Scope Chain - Variable
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
//JavaScript Scope Chain | |
var mytxt = 'test1'; | |
function echo() { | |
console.log("A-->" + mytxt); | |
var mytxt = 'test2'; | |
console.log("B-->" + mytxt); | |
} | |
echo(); | |
/* | |
The result is not | |
A-->test1 | |
B-->test2 | |
it's | |
A-->undefined | |
B-->test2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment