Created
September 18, 2016 04:36
-
-
Save jkoppel/3f65e316ec921a90ee5228f771da4a5d to your computer and use it in GitHub Desktop.
This file contains 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
// Version 1: Prints "1" | |
function foo() { | |
x = 1; | |
} | |
foo(); | |
console.log(x); | |
//------------------------------------ | |
// Version 2: Gives "ReferenceError: x is not defined" | |
function foo() { | |
x = 1; | |
var x = 2; | |
} | |
foo(); | |
console.log(x); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment