Last active
December 27, 2015 03:29
-
-
Save alxhub/7259670 to your computer and use it in GitHub Desktop.
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
// What you have | |
x = 1; | |
function foo() { | |
x = 2; | |
} | |
foo(); | |
return x; // Gives 1 | |
// What he wants | |
x = 1 | |
function foo() { | |
x = 2; | |
} | |
foo(); | |
return x; // Gives 2 | |
// Also what he wants (meaning of "doesn't leak"): | |
function foo() { | |
x = 2; | |
} | |
foo(); | |
return x; // Error - first definition of 'x' doesn't leak into outer scope |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment