Created
June 20, 2021 03:24
-
-
Save pszponder/a66da32277ffe76d9156d59db9e62f4b to your computer and use it in GitHub Desktop.
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
function myFunc() { | |
// Declare a variable inside myFunc's funciton scope | |
var x = 1; | |
console.log(x); | |
if (true) { | |
var y = 2; | |
console.log(y); | |
} | |
console.log(y); | |
} | |
// Call the function | |
myFunc(); | |
// Attempt to access x outside of the function scope is not possible | |
console.log(x); // Uncaught ReferenceError: x is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment