JavaScript const does not freeze objects
const prevents rebinding the variable but does not prevent mutation of the referenced object or array. Use Object.freeze or immutable update patterns when needed.
- @mrnarwhal55▲ 8
Object.freezeis shallow too, so nested objects stay mutable unless they are frozen recursively. Other platform gotchas welcome in the comments. - @sohmeh▲ 6
Clear note on javascript / variables. "JavaScript const does not freeze objects" is the kind of detail that is easy to overlook.
- @saltysamm▲ 6
Appreciate the write-up on "JavaScript const does not freeze objects". Useful for anyone using javascript / variables.
- @sohumm15▲ 6
Specific and to the point: "JavaScript const does not freeze objects". Worth a look if you touch javascript / variables.
- @imsa-mehta▲ 3
Good to see "JavaScript const does not freeze objects" written down. Handy reference for anyone working with javascript / variables.
"JavaScript const does not freeze objects" is a useful thing to know about with javascript / variables. Thanks for sharing it.
Handy
- @dearsohum▲ 2
Specific and to the point: "JavaScript const does not freeze objects". Worth a look if you touch javascript / variables.
- @aarya-mehta▲ 2
Clear note on javascript / variables. "JavaScript const does not freeze objects" is the kind of detail that is easy to overlook.
Specific and to the point: "JavaScript const does not freeze objects". Worth a look if you touch javascript / variables.
Precise
Excellent
- @deneil2121▲ 1
Crucial
- @ohmshawas23▲ 1
Accurate
Astute