Object.freeze, seal, and Immutability Patterns
Built-in methods for restricting how much an object can be changed, and why true deep immutability requires more than a single call.
JavaScript objects are mutable by default, and Object.freeze() and Object.seal() are the built-in tools for restricting that mutability, though neither goes as deep as many developers initially assume, which makes for a good interview trap question. Immutability patterns matter broadly in state management (Redux, React) where predictable, non-mutated data is central to how change detection and re-rendering work.
Object.freeze is like laminating the cover page of a document — the cover itself can't be altered anymore, but if the cover references a separate folder full of loose pages (a nested object), those loose pages are still completely free to be rewritten unless you laminate every single page inside that folder too.