Facebook Pixel

Does const make objects immutable in JavaScript?

No. const prevents reassignment of the variable, but you can still mutate the object's properties. Use Object.freeze() if you want true immutability.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in var vs let vs const Hoisting in JavaScript

var is hoisted and initialized to undefined. let and const are hoisted (memory allocated) but kept uninitialized in the Temporal Dead Zone. Accessing them before the declaration line throws a ReferenceError.

Yes, memory is allocated for them. But they remain in the Temporal Dead Zone until the declaration line is reached. Accessing them early throws a ReferenceError, unlike var which returns undefined.

The period between the start of a block scope and the line where a let or const variable is declared. During this period, accessing the variable throws a ReferenceError.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.