The find(testingFunc) method

The + method of an array returns an array element if it satisfies the provided testing function. Otherwise, it returns undefined.

The find() method takes two arguments; that is, the first argument is the testing function and the second argument is the value of this in the testing function. The second argument is optional.

The testing function has three parameters: the first parameter is the array element being processed, the second parameter is the index of the current element being processed, and the third parameter is the array on which find() is called.

The testing function needs to return true to satisfy a value. The find() method returns the first element which satisfies the provided testing function.

Here ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.