API reference / @evolu/common / Array / lastInArray
Function: lastInArray()
function lastInArray<T>(array): T;
Defined in: packages/common/src/Array.ts:398
Returns the last element of a non-empty array.
Accepts both mutable and readonly arrays. Does not mutate the original array.
Example
lastInArray(["a", "b", "c"]); // "c"
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
array | readonly [T, T] |
Returns
T