First

Returns the first element of an array.

CategoryArrays
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    first([1, 2, 3])

    Output:

    1

Return

The first element of the array or `undefined` if the array is empty.

Type: T | undefined

Props

NameTypeDefaultRequiredDescription
arrT[]nullYesThe array to get the first element from.

Notes

Returns `undefined` if the array is empty.

Tags

  • array
  • first
  • element

Related