last
The last() method returns the last element of an array.
Interactive example
Syntax
typescript
function last<
GenericInput extends readonly unknown[]
>(
input: GenericInput
): GenericInput extends readonly [...any[], infer InferredValue]
? InferredValue
: GenericInput[number] | undefinedParameters
input: The array from which to retrieve the last element.
Return value
The last element of the array, or undefined if the array is empty.
