Skip to main content

Harshal V. LADHE

Using Object.freeze() in JavaScript

How `Object.freeze()` locks an object's properties, where its shallow behaviour falls short, and how to freeze nested structures.

Content tagged Object.freeze

  • Snippet:Deep Freeze Objects in JavaScript

    Recursively lock every object level for true immutability
    Lock objects and their children immutably — prevent accidental mutations and enforce deep immutability in strict mode.
    Published at:
    Categories:JavaScript
    Estimated reading time:2 min read