what does find return javascript 1

what does find return javascript

The find() method returns the value of the first element 
in the provided array that satisfies the provided testing function. 

Here is what the above code is Doing:
1. The find() method executes the callback function once for each element present in the array:

If it finds an array element where the callback function returns a true value, find() returns the value of that array element (and does not check the remaining values)
Otherwise it returns undefined

2. The callback function accepts three arguments:

The value of the element
The index of the element
The Array object being traversed

3. If the thisArg parameter is provided to find(), it will be used as the this value for each invocation of the callback function. If it is not provided, then undefined is used.

4. findIndex() is like find(), but it returns the index of the first element that passes the test instead of the element itself.

5. find() does not mutate or change the original array.

Similar Posts