requireLast()function
requireLast(items: PossibleArray<T>, caller: AnyCaller = requireLast): T
| Param | Type | |
|---|---|---|
items | PossibleArray<T> | The array or iterable to read from. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to requireLast itself). Defaults to requireLast |
| Return | |
|---|---|
T | The last item. |
| Throws | |
|---|---|
RequiredError | If items is empty. |
Get the last item from an array or iterable.
Examples
requireLast([1, 2, 3]) // 3