const
Last updated
const foo = 123
foo = 456 // ERROR: Left-hand side of an assignment expression cannot be a constantconst foo = 123
if (true) {
const foo = 456 // Allowed as its a new variable limited to this `if` block
}const foo = { bar: 123 }
foo = { bar: 456 } // ERROR : Left hand side of an assignment expression cannot be a constantconst foo = { bar: 123 }
foo.bar = 456 // Allowed!
console.log(foo) // { bar: 456 }