OutputNot attempted
Object.freeze in strict mode
const cfg = Object.freeze({ level: 1, inner: { level: 1 } });try { cfg.level = 2;} catch (e) { console.log(e.name);}cfg.inner.level = 2;console.log(cfg.level, cfg.inner.level);Spaces and quote style don’t matter · write a thrown error as TypeError
Ctrl Enter
Show answer & explanation
The expected output comes from actually running the snippet; opening this shows it next to the explanation.
Writing to a frozen object throws TypeError in strict mode (silently ignored in sloppy). freeze is SHALLOW: inner is still mutable.