last
@guoba-ai/utils / array / last
Function: last()
function last<T>(array): T | undefined;Defined in: array.ts:155
Get the last element of an array.
Parameters
array
T[]
The input array
Returns
T | undefined
The last element, or undefined if empty
Example
last([1, 2, 3]) // 3
last([]) // undefined
last(['only']) // 'only'