First
Returns the first element of an array.
Category | Arrays |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Sync |
Compatibility | Universal |
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
Name | Type | Default | Required | Description |
---|---|---|---|---|
arr | T[] | null | Yes | The array to get the first element from. |
Notes
Returns `undefined` if the array is empty.
Tags
- array
- first
- element