jty
    Preparing search index...

    Function isEqualArr

    • Checks if two arrays are the same. Two arrays are considered the same if they have the same length and their elements are strictly equal at each index. This function acts as a type guard, narrowing the type of b to be the same as a if it returns true.

      Type Parameters

      • T

      Parameters

      • x: unknown

        The first value to compare.

      • ref: T[]

        The reference array.

      Returns x is T[]

      true if the arrays are the same, false otherwise.

      isEqualArr([1, 2, 3], [1, 2, 3]) => true
      isEqualArr([1, 2, 3], [1, 2, 3, 4]) => false
      isEqualArr([1, 2, 3, 4], [1, 2, 3]) => false
      isEqualArr([], []) => true
      isEqualArr([], [1, 2, 3]) => false
      isEqualArr({}, [1, 2, 3]) => false
      isEqualArr([1, 2, 3], [3, 2, 1]) => false

      if ref is not an array.