JavaScript

Object.freeze vs Object.seal

Medium
2
Added
freeze: No changes allowed. seal: Prevents adding/removing properties but allows modifying.

Solution Code

JavaScript
const obj = { a: 1 };
Object.freeze(obj);
obj.a = 2; // Silent failure
Explanation
Both create shallow immutability. Use strict mode to throw errors.

Guided Hints

Deep freezing techniques
Object.preventExtensions