Where this matters
A constant binding is useful for keeping the same settings object while allowing its properties to change.
const user = { level: 1 };
user.level = 2;
console.log(user.level);Read the full explanation
Const prevents rebinding user. Updating a property on the same object is permitted.
Trace the code
- user refers to one object whose level begins at 1.
- The property assignment changes that object; it does not assign a different object to user.
- Reading user.level therefore sees the updated property.
Why the other predictions differ
1— Const does not freeze the object’s properties.TypeError— Reassigning user itself would fail; this statement changes only a property.
2
Reading this explanation does not record mastery. A correct submitted attempt can do so, including after review.
Change one thing
Rebind user to a new object instead. Catch the error so you can compare its kind with a permitted property update.
Predict the result, then run this self-contained snippet in your browser’s developer console. It uses only sample values and makes no network requests.
const user = { level: 1 }; try { user = { level: 2 }; } catch (error) { console.log(error.name); }Check the variation’s output
TypeError
Explain which binding, value, or operation changed before moving to the next challenge.