xdash API Reference / first
Function: first()
first<
T
>(arr
):T
Defined in: src/array.ts:38
Returns the first element of an array
Type Parameters
T
T
Parameters
arr
T
[]
array to get the first element from
Returns
T
the first element of the array
Throws
if the array is empty
Example
ts
first([1, 2, 3]) // returns 1
first([]) // throws an error