

Elements that are appended to the array after the call to find begins will not be visited by callback. The range of elements processed by find is set before the first invocation of callback.

If it is not provided, then undefined is used.įind does not mutate the array on which it is called. If a thisArg parameter is provided to find, it will be used as the this for each invocation of the callback. callback is invoked only for indexes of the array which have assigned values it is not invoked for indexes which have been deleted or which have never been assigned values.Ĭallback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed. If such an element is found, find immediately returns the value of that element. The find method executes the callback function once for each element present in the array until it finds one where callback returns a true value. Return valueĪ value in the array if an element passes the test otherwise, undefined. Object to use as this when executing callback. index The index of the current element being processed in the array.

find(callback ) Parameters callback Function to execute on each value in the array, taking three arguments:Įlement The current element being processed in the array.
