Problem Statement
Compare Object.preventExtensions, Object.seal, and Object.freeze.
Explanation
preventExtensions: disallows adding new properties.
seal: disallows adding/removing properties and marks existing properties as non-configurable (values can still change if writable).
freeze: like seal, but also makes data properties non-writable (no changes allowed to values).
Code Solution
SolutionRead Only
const obj = { x: 1 };
Object.preventExtensions(obj);
// obj.y = 2; // TypeError in strict mode
const sealed = Object.seal({ a: 1 });
// delete sealed.a; // false
sealed.a = 5; // allowed
const frozen = Object.freeze({ b: 1 });
// frozen.b = 2; // TypeError in strict mode