firstElement() Function
Returns the first element in array
whose value satisfies the predicate
.
Signature
export declare function firstElement<T>(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
array | readonly T[] | The array to search. |
predicate | (value: T, index: number, array: readonly T[]) => boolean | A predicate. There should exist some index |
(Returns) | T | undefined | The first element in |