Array.prototype.find

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

Syntax

find(predicate, thisArg?)

Parameters

Return value

An array element or undefined.

Example

["coffee", "tea", "juice"].find(x => x.length == 3)
"tea"
["coffee", "tea", "juice"].find(x => x.length == 10000)
undefined
[1, 2, 3, 4, 5].find(x => x > 2)
3