Do you know what will be the output of this code?
JavaScript
const obj = Object.freeze({ a: 1, inner: { b: 1 } });
obj.a = 2;
obj.inner.b = 2;
console.log(obj.a, obj.inner.b);
Show answer and explanation
The answer is 1 2.
Object.freeze is shallow. The change to obj.a is ignored (in strict mode it throws), but inner is a separate object that isn’t frozen.