Created
May 6, 2016 18:07
-
-
Save emilong/f4e844a3977422b64e339f84fa7af47c to your computer and use it in GitHub Desktop.
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
const foo = (a) => { | |
// x will stay 1 forevar | |
const x = 1 | |
if (a === 1) { | |
// this declaration of y is scoped only to this block | |
const y = 3 | |
// both x and y are defined here, as you'd expect | |
console.log('x', x) // x 1 | |
console.log('y', y) // y 3 | |
} else { | |
// this is a different declaration of y from above and is totes legit | |
const y = 4 | |
// both x and y are defined here, as you'd expect | |
console.log('x', x) // x 1 | |
console.log('y', y) // y 4 | |
} | |
// y is not defined here | |
console.log('x', x) // x 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment