Skip to content

Instantly share code, notes, and snippets.

@aeris
Created September 2, 2015 09:46
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 aeris/7dee78d809a1f0d9dc1d to your computer and use it in GitHub Desktop.
Save aeris/7dee78d809a1f0d9dc1d to your computer and use it in GitHub Desktop.
JS scoping hell
var val = 1;
function foo() {
print(val);
val = 2;
print(val);
}
function bar() {
var val = 3;
print(val);
}
function baz() {
print(val);
var val = 4;
print(val);
}
print(val);
foo();
print(val);
bar();
print(val);
baz();
print(val);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment