Skip to content

Instantly share code, notes, and snippets.

@lenafaure
Last active July 5, 2017 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenafaure/251a3f96da34011e0ca53d6e18eff920 to your computer and use it in GitHub Desktop.
Save lenafaure/251a3f96da34011e0ca53d6e18eff920 to your computer and use it in GitHub Desktop.
Local and global variable scope
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