Created
March 26, 2023 10:06
-
-
Save makstyle119/e2436deb16e8a4001f47198794c6609f to your computer and use it in GitHub Desktop.
Scope of Variables
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
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