Reassigning constants
suggest changeYou can't reassign constants.
const foo = "bar";
foo = "hello";
Prints:
Uncaught TypeError: Assignment to constant variable.
The wording of the TypeError depends on the engine. Reassigning a const binding is what throws. The binding’s contents can still be mutated when the value is an object.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents