last
last<T>(array: T[]): T | undefinedSource: array.ts:434
Gets the last element of an array
Type Parameters
T— Array element type
Parameters
array(T[]) — The input array
Returns
T | undefined— Last element or undefined
Example
CODE
last([1, 2, 3]) // 3
last([]) // undefined