Skip to content

Instantly share code, notes, and snippets.

@sespinosa
Created July 24, 2018 01:45
Show Gist options
  • Save sespinosa/af2c60503d98edd9b13da2c8b3945ba7 to your computer and use it in GitHub Desktop.
Save sespinosa/af2c60503d98edd9b13da2c8b3945ba7 to your computer and use it in GitHub Desktop.
Let example (scope)
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