Standard built-ins

Array.prototype.findLastIndex()

Try the free JavaScript compiler

Visits indices in descending order until a truthy predicate result. Reads ordinary holes as undefined and supplies value, index and source to the predicate. Matching index, or -1 if none qualifies.

Formal Syntax & Structure

javascript syntaxjavascript
array.findLastIndex(predicate, thisArg?)

Parameters & Attributes

NameTypeDescription
predicatefunctionTests the current value, index and source.
thisArganyOptional callback receiver.

Return Value

number

Matching index, or -1 if none qualifies.

Working Example

Example Snippetjavascript
console.log([1,7,2,9].findLastIndex(x=>x>5));
JavaScript Reference