Created
June 9, 2019 13:12
-
-
Save CodeDraken/833d202c17bc458e05dff8a698faa60c to your computer and use it in GitHub Desktop.
Demonstrating the scope, scope chain
This file contains hidden or 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
| // scope & scope chain | |
| function a() { | |
| var myOtherVar = 'inside A' | |
| b() | |
| } | |
| function b() { | |
| var myVar = 'inside B' | |
| console.log('myOtherVar:', myOtherVar) | |
| function c() { | |
| console.log('myVar:', myVar) | |
| } | |
| c() | |
| } | |
| var myOtherVar = 'global otherVar' | |
| var myVar = 'global myVar' | |
| a() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment