Last
Returns the last element of an array.
| Category | Arrays | 
| Author | Pol Gubau | 
| Since | 1.0.0 | 
| Last Updated | 2025-03-15 | 
| Type | Sync | 
| Compatibility | Universal | 
Example
Input
last([1, 2, 3])Output:
3
Return
The last 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 last element from. | 
Notes
Returns `undefined` if the array is empty.
Tags
- array
 - last
 - element