MediumModern JS💻 Output Question

Object.freeze prevents mutation silently

💡

Hint

Object.freeze: mutations silently fail (non-strict mode). Frozen objects cannot be changed.

What does this output?

const obj = Object.freeze({ x: 1, y: 2 });
obj.x = 99;
obj.z = 3;
console.log(obj.x);
console.log(obj.z);

Correct Output

1
undefined

Why this output?

Explanation: Object.freeze makes all properties non-writable. Assignments silently fail in non-strict mode.

Key Insight: Object.freeze: mutations silently fail (non-strict mode). Frozen objects cannot be changed.

More Modern JS Output Questions

EasyDestructuring defaults apply only for undefinedEasyObject spread — later properties winMediumOptional chaining prevents TypeError on missing propertiesMediumNullish coalescing ?? vs OR ||

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz