Last active
July 5, 2017 13:21
-
-
Save lenafaure/251a3f96da34011e0ca53d6e18eff920 to your computer and use it in GitHub Desktop.
Local and global variable 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 greeting = "Hi, I am a global variable"; // global scope variable | |
function sayHello() { | |
var greeting = "Hi, I am a local variable"; // local scope variable | |
console.log(greeting); | |
} | |
sayHello(); // Prints "Hi, I am a local variable" | |
console.log(greeting); // Prints "Hi, I am a global variable" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment