JavaScript Array find() Method
The array.find(function(currentValue, index, array), thisValue) method in JavaScript is used to get the value of the first element in an array that matches a given condition. The find() method examines all array elements, and the first element that satisfies the condition will be returned. The find() method will not invoke a callback function on empty array elements, nor will it modify the original array.
Where:
- function: a function will be executed once for each element in the array until it returns the boolean true or reaches the end of the array. If you pass an object instead of a function, then a TypeError exception will be raised.
- thisValue (optional): an object that can be referenced by the "this" keyword inside the callback function. If thisValue parameter is not passed, "this" will be "undefined"