head es-toolkit
Returns the first element of an array.
Usage
head(arr)
Use head when you want to get the first element of an array. If the array is empty, it returns undefined. This is useful when accessing data at the beginning of an array.
Type handling is safe.
Parameters
arrreadonly T[]required
The array from which to get the first element.
Returns
The first element of the array. Returns undefined if the array is empty.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.