Reassigning constants

suggest change

You 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents