Created
May 6, 2016 18:17
-
-
Save emilong/249ceaa48499d011d28dfc5b0c0479f2 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 assignLater = (a) => { | |
const x | |
if (a === 1) { | |
x = 1 // XXX nope, must assign at declaration time | |
} else { | |
x = 2 // XXX nope, must assign at declaration time | |
} | |
} | |
const shadowVars = () => { | |
var v | |
let el | |
const v = 1, el = 2 // XXX cannot redeclare as const | |
} | |
const reassignDuh = () => { | |
const v = 1 | |
v = 2 // XXX come on... | |
} | |
const redeclare = () => { | |
const v = 1 | |
const v = 1 // XXX not even if the value is the same | |
} | |
const outsideScope = (a) => { | |
if (a === 1) { | |
// this declaration of y is scoped only to this block | |
const y = 3 | |
} | |
console.log('y', y) // XXX y is not defined here | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment