Javascript array find() is an inbuilt js function that returns the value of the first item in the Array that satisfies a provided testing function. Otherwise,  undefined will be returned. The array find() method returns the value of the first element in an array that passes a test of provided function.

If an Array find() method finds an item where the function returns a true value. Javascript find() returns the value of that array item immediately and does not check the remaining values of that Array.

Javascript array find

Javascript Array.find() is the inbuilt function that is used to get a value of the first item in the Array that meets the provided condition. If you need an index of the found item in the Array, use the  findIndex(). If you need to find an index of the value, use Array  .prototype.indexOf(). If you need to find if the value exists in an array, use Array  .prototype.includes().

It checks all the items of the Array, and whichever the first item meets, the condition is going to print. If more than one item meets the condition, then the first item satisfying the requirement is returned. Suppose that you want to find the first odd number in the Array. The argument function checks whether an argument passed to it is an odd number or not.

Javascript find() function calls an argument function for every item of the Array.  The first odd number for which argument function returns true is reported by the find() function as the answer.

#javascript #javascript find #array.find

Javascript array find: How to Find Element in Javascript
13.70 GEEK