tguard-js
    Preparing search index...

    Function isFrozen

    • Determines whether the provided value is a frozen object.

      Important Note:
      JavaScript considers an object "frozen" if it is non-extensible and all of its properties are non-configurable and non-writable.

      This leads to a subtle edge case:

      • An empty object ({}) that is sealed or made non-extensible is also considered frozen, even if Object.freeze was never called.

      Type Parameters

      • T extends object

        The type of the input value.

      Parameters

      • o: unknown

        The value to be checked.

      Returns o is Readonly<T>

      true if the value is a frozen object, otherwise false.

      A frozen object is an object whose properties:

      • cannot be added or removed
      • cannot be reconfigured
      • cannot be reassigned (all properties are effectively read-only)

      This function only returns true for actual object values. It avoids the coercion behavior of Object.isFrozen, which returns true for all non-object (primitive) values.

      Value Result Object.isFrozen
      Object.freeze( {} ) true true
      Object.seal( {} ) true true
      {} false false
      [] false false
      null false true
      undefined false true
      123 false true

      1.0