OutputNot attempted
seal vs freeze
const sealed = Object.seal({ item: 'Phone' });const frozen = Object.freeze({ item: 'Phone' });const attempt = (label, fn) => { try { fn(); console.log(label, 'ok'); } catch (e) { console.log(label, e.name); }};attempt('seal modify', () => { sealed.item = 'Laptop'; });attempt('seal add', () => { sealed.extra = 1; });attempt('seal delete', () => { delete sealed.item; });attempt('freeze modify', () => { frozen.item = 'Laptop'; });console.log(sealed.item, frozen.item);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.
seal = configurable:false + non-extensible: you can still CHANGE existing values but not add or delete. freeze also sets writable:false, so nothing changes. In strict mode every blocked operation throws TypeError.