Skip to content

Instantly share code, notes, and snippets.

@CodeDraken
Created June 9, 2019 13:12
Show Gist options
  • Select an option

  • Save CodeDraken/833d202c17bc458e05dff8a698faa60c to your computer and use it in GitHub Desktop.

Select an option

Save CodeDraken/833d202c17bc458e05dff8a698faa60c to your computer and use it in GitHub Desktop.
Demonstrating the scope, scope chain
// 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