As we read further, we get to this line: “The
const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable—just that the variable identifier cannot be reassigned.” The VERY important piece here is that the VALUE IS NOT IMMUTABLE.
Immutable? What the heck does immutable mean? Well, if an object is immutable, for that instance the properties cannot be changed. But since const objects are NOT immutable; it means that a const object can have its properties changed within it.
Looking at a code example, this is a valid usage of const where we change the non-immutable value of an underlying property.
Now, it wouldn’t be called const if everything was not constant about our objects. In the docs, we see that “the variable identifier cannot be reassigned”. What this means is that we cannot completely reassign our const reference.
The following code is an example of what we CANNOT do with a const: