Function firstItem

Returns the first item of an array.

at

firstItem([1, 2, 3]); // => 1
firstItem([]); // => undefined
  • Type Parameters

    • S extends readonly unknown[]

    Parameters

    • source: S

    Returns IfExtends<
        IsNonEmptyArray<S> extends true ? S[0] : undefined | S[number],
        undefined | S[number],
    >

    The first item of the array, or undefined if the array is empty.