ECMAScript const objects are references

A note about const in JavaScript, which is not a constant, but a way to solve some JavaScript problems related to block scopes.

Read more:

MDN. JavaScript. const

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. For instance, in the case where the content is an object, this means the object’s contents (e.g., its parameters) can be altered. (edited)

ES2015 const is not about immutability

const is not about immutability

const makes the contract that no rebinding will happen

Constant Variables in JavaScript, or: When “const” Isn’t Constant

Unfortunately, the name of the const keyword might be misleading. In JavaScript, const does not mean constant, but one-time assignment. It’s a subtle yet important distinction. Let’s see what one-time assignment means..