The find()
method executes the callbackFn
function once for each element present in the typed array until it finds one where callbackFn
returns a true value. If such an element is found, find()
immediately returns the value of that element. Otherwise, find()
returns undefined
. callbackFn
is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callbackFn
is invoked with three arguments: the value of the element, the index of the element, and the typed array object being traversed.
If a thisArg
parameter is provided to find()
, it will be used as the this
for each invocation of the callbackFn
. If it is not provided, then undefined
is used.
find()
does not mutate the typed array on which it is called.
The range of elements processed by find()
is set before the first invocation of callbackFn
. Elements that are appended to the typed array after the call to find()
begins will not be visited by callbackFn
. If an existing, unvisited element of the typed array is changed by callbackFn
, its value passed to the visiting callbackFn
will be the value at the time that find()
visits that element's index; elements that are deleted are not visited.