Skip to content

Instantly share code, notes, and snippets.

@emilong
Created May 6, 2016 18:17
Show Gist options
  • Save emilong/249ceaa48499d011d28dfc5b0c0479f2 to your computer and use it in GitHub Desktop.
Save emilong/249ceaa48499d011d28dfc5b0c0479f2 to your computer and use it in GitHub Desktop.
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