getFirst()function

getFirst(items: PossibleArray<T>): T | undefined
ParamType
itemsPossibleArray<T>
The array or iterable to read from. required
Return
T | undefined
The first item, or undefined if items is empty.

Get the first item from an array or iterable, or undefined if it didn't exist.

Examples

getFirst([1, 2, 3]) // 1