@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function lastArrayItem

    • Returns the last element of an array. When called with a non-empty tuple, the return type is T (not T | undefined).

      Type Parameters

      • T

      Parameters

      • array: readonly [T, T]

        The source array.

      Returns T

      lastArrayItem([1, 2, 3]) // => 3
      lastArrayItem([]) // => undefined
    • Returns the last element of an array. When called with a non-empty tuple, the return type is T (not T | undefined).

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The source array.

      Returns T | undefined

      lastArrayItem([1, 2, 3]) // => 3
      lastArrayItem([]) // => undefined