const
The const keyword only makes the binding immutable, that is, you can only assign a value to a const variable once. In JavaScript, only Primitives values are immutable. However, non-primitive values can still be mutated.
const MY_FIRST_CONSTANT = 10;
// Can not be re-assigned.
MY_FIRST_CONSTANT = 20;
// => TypeError: Assignment to constant variable.
const MY_MUTABLE_VALUE_CONSTANT = { food: 'apple' };
// This is possible
MY_MUTABLE_VALUE_CONSTANT.food = 'pear';
MY_MUTABLE_VALUE_CONSTANT;
// => { food: "pear" }
Backlinks