JavaScript · Junior · Question 5 of 75
What happens?
const user = { name: "Ann" };
user.name = "Bob";- ✓Correct answer: It works:
constforbids reassignment, not mutation of the object - 2
TypeError: properties of aconstobject can't be changed - 3The change is silently ignored and
namestays"Ann"
Explanation
const fixes the reference: user = {} throws, but the object's contents can change. To prevent property changes, use Object.freeze (shallowly).