Yes. const prevents reassigning the array variable, but you can still mutate the array with push, pop, splice, and index assignment. Use Object.freeze (or Object.freeze(arr)) to prevent mutations.
const with Objects and Arrays in JavaScript
Can you push to a const array in JavaScript?
The answer
More FAQs in const with Objects and Arrays in JavaScript
No. const prevents reassignment of the variable, but you can still mutate the object's properties (add, change, delete). Use Object.freeze for immutability.
const prevents reassignment of the variable binding. Object.freeze prevents mutation of the object itself (no property changes, additions, or deletions). They work at different levels: const is about the variable, freeze is about the value.
Shallow. Object.freeze prevents changes to the top-level object's properties, but nested objects can still be mutated. For deep immutability, you need a recursive deepFreeze function.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.