Finds the first element in the source array that satisfies the provided predicate function.
Returns undefined if no element satisfies the predicate.
undefined
const findPositive = find((x: number) => x > 0);const a = findPositive([1, 2, 3]); // 1const b = findPositive([-1, 0, -2]); // undefined Copy
const findPositive = find((x: number) => x > 0);const a = findPositive([1, 2, 3]); // 1const b = findPositive([-1, 0, -2]); // undefined
Finds the first element in the source array that satisfies the provided predicate function.
Returns
undefinedif no element satisfies the predicate.Example