Function head

  • Gets the first element of array.

    Type Parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array to query.

    Returns T | undefined

    Returns the first element of array.

    Since

    5.0.0

    Alias

    first

    See

    last

    Example

    head([1, 2, 3])
    // => 1

    head([])
    // => undefined