The array or array like object of elements to be searched.
A function that accepts up to three arguments of type ArrPredicateCallbackFn or ArrPredicateCallbackFn2. The predicate function is called for each element in the thArray until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
Optional
thisArg: anyA value to use as this when executing callbackFn. Defaults to the array if not provided.
The last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
The arrFindLast() method iterates the array in reverse order and returns the value of the first element that satisfies the provided testing function. If no elements satisfy the testing function, undefined is returned.
The arrFindLast() method is an iterative method. It calls a provided callbackFn function once for each element in an array in descending-index order, until callbackFn returns a truthy value. arrFindLast() then returns that element and stops iterating through the array. If
callbackFn
never returns a truthy value, arrFindLast() returns undefined.callbackFn
is invoked for every index of the array, not just those with assigned values. Empty slots in sparse arrays behave the same as undefined.arrFindLast() does not mutate the array on which it is called, but the function provided as
callbackFn
can. Note, however, that the length of the array is saved before the first invocation ofcallbackFn
. Therefore:callbackFn
will not visit any elements added beyond the array's initial length when the call to arrFindLast() began.callbackFn
, its value passed to thecallbackFn
will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.Since
0.8.0
Example