Skip to content

Instantly share code, notes, and snippets.

@makstyle119
Created March 26, 2023 10:06
Show Gist options
  • Save makstyle119/e2436deb16e8a4001f47198794c6609f to your computer and use it in GitHub Desktop.
Save makstyle119/e2436deb16e8a4001f47198794c6609f to your computer and use it in GitHub Desktop.
Scope of Variables
let globalVariable = "I am global";
function myFunction() {
let localVariable = "I am local";
console.log(globalVariable); // "I am global"
console.log(localVariable); // "I am local"
}
myFunction();
console.log(globalVariable); // "I am global"
console.log(localVariable); // ReferenceError: localVariable is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment