Skip to content

xdash API Reference v0.5.14


xdash API Reference / last

Function: last()

last<T>(arr): T

Defined in: src/array.ts:12

Returns the last element of an array

Type Parameters

T

T

Parameters

arr

T[]

array to get the last element from

Returns

T

the last element of the array

Throws

if the array is empty

Example

ts
last([1, 2, 3]) // returns 3
last([]) // throws an error

Released under the MIT License.