Created
April 30, 2017 08:41
-
-
Save lenafaure/e0ec3542bcfa5086b0c5145e4ccc5b73 to your computer and use it in GitHub Desktop.
The var keyword and the scope
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
var myVariable = "Hi, I am a global variable"; | |
function sayHello() { | |
myVariable = "Hi, I am locally produced!"; | |
console.log(myVariable); | |
} | |
console.log(myVariable); // Prints "Hi, I am a global variable" | |
sayHello(); // Prints "Hi, I am locally produced!" | |
console.log(myVariable); // Prints "Hi, I am locally produced!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment