map.apps Bundle APIs 4.20.0
    Preparing search index...

    Function freeze

    • Freezes an object or array deeply. The given obj is frozen deeply, no changes can be made after that on the obj nor its children after that.

      Type Parameters

      • T

      Parameters

      • obj: T

        Object to freeze. Should be an object or an array, otherwise has on effect.

      Returns DeepFrozen<T>

      Always returns obj.

      import freeze from "apprt-core/freeze";
      let src = {x: 1, y: { a: 2 } };
      let srcFrozen = freeze(src);
      src === srcFrozen // -> true
      src.x = 3 // still 1, change not possible
      src.y.a = 3 // still 2, change not possible