@s-libs/js-core
    Preparing search index...

    Function isEqualAtDepth

    • Performs a deep comparison between two values to determine if they are equivalent, up to the given depth. Once that depth is reached, remaining values are compared using Object.is().

      let object1 = "a";
      let object2 = "a";
      isEqualAtDepth(0, object1, object2); // true
      isEqualAtDepth(1, object1, object2); // true

      let object1 = { a: 1 };
      let object2 = { a: 1 };
      isEqualAtDepth(0, object1, object2); // false
      isEqualAtDepth(1, object1, object2); // true

      object1 = { a: [1, 2, 3], d: { e: 1 } };
      object2 = { a: [1, 2, 3], d: { e: 1 } };
      isEqualAtDepth(0, object1, object2); // false
      isEqualAtDepth(1, object1, object2); // false
      isEqualAtDepth(2, object1, object2); // true
      isEqualAtDepth(3, object1, object2); // true

      Parameters

      • depth: number
      • value: unknown
      • other: unknown

      Returns boolean