Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
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