Skip to content

Instantly share code, notes, and snippets.

@aeris
Created Sep 2, 2015
Embed
What would you like to do?
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