tguard-js
    Preparing search index...

    Function isSealed

    • Determines whether the provided value is a sealed object.

      Important Note:
      Empty objects ({}) that are made non-extensible (via Object.preventExtensions) are also considered sealed, since there are no properties that violate the constraint.

      Type Parameters

      • T extends object

        The type of the input value.

      Parameters

      • o: T

        The value to be checked.

      Returns o is T

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

      A sealed object is an object whose properties:

      • cannot be added or removed
      • cannot be reconfigured

      However, existing property values may still be changed if they are writable.

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

      In contrast, Object.isSealed treats primitives such as null, undefined, numbers, and strings as already sealed, which can lead to misleading results when performing runtime validation.

      Value Result Object.isSealed()
      Object.freeze( {} ) true true
      Object.freeze( [] ) true true
      Object.seal( {} ) true true
      Object.seal( [] ) true true
      {} false false
      [] false false
      new Date() false false
      null false true
      undefined false true
      123 false true
      'text' false true

      1.0