Logos DX
    Preparing search index...

    Function isSameLength

    • Checks if both values have the same length or size.

      Compares the length property for arrays or size property for Sets. Both iterables must be the same data type (both arrays or both Sets). Useful for validating collections before performing operations.

      Type Parameters

      Parameters

      • a: A

        first collection (array or Set)

      • b: B

        second collection (array or Set) - must be same type as a

      Returns boolean

      true if both collections have the same length/size

      isSameLength([1, 2, 3], ['a', 'b', 'c']) // true
      isSameLength([1, 2], [1, 2, 3]) // false
      isSameLength(new Set([1, 2]), new Set(['a', 'b'])) // true
      isSameLength(new Set([1, 2]), new Set([1, 2, 3])) // false