Created
July 24, 2018 01:45
-
-
Save sespinosa/af2c60503d98edd9b13da2c8b3945ba7 to your computer and use it in GitHub Desktop.
Let example (scope)
This file contains hidden or 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 x = 1 | |
var y = 1 | |
console.log("\nInitial Values") | |
console.log("x: ", x) | |
console.log("y: ", y) | |
/* OUTPUT: | |
* x: 2 | |
* y: 2 | |
*/ | |
if (x === 1 && y === 1) { | |
let x = 2 | |
var y = 2 | |
console.log("\nInside scope") | |
console.log("x: ", x) | |
console.log("y: ", y) | |
/* OUTPUT: | |
* x: 2 | |
* y: 2 | |
*/ | |
} | |
console.log("\nOutside scope") | |
console.log("x: ", x) | |
console.log("y: ", y) | |
/* OUTPUT: | |
* x: 1 | |
* y: 2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment