The findIndex()
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, findIndex()
immediately returns the index of that element. Otherwise, findIndex()
returns -1. 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 findIndex()
, it will be used as the this
for each invocation of the callback
. If it is not provided, then undefined
is used.
findIndex()
does not mutate the typed array on which it is called.
The range of elements processed by findIndex()
is set before the first invocation of callbackFn
. Elements that are appended to the typed array after the call to findIndex()
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 findIndex()
visits that element's index; elements that are deleted are not visited.