xdash API Reference / lastOrDefault
Function: lastOrDefault()
lastOrDefault<
T,D>(arr,defaultValue):T|D
Defined in: src/array.ts:25
Returns the last element of an array, or a default value if the array is empty.
Type Parameters
T
T
D
D
Parameters
arr
T[]
array to get the last element from
defaultValue
D
default value
Returns
T | D
the last element of the array, or the default value if the array is empty