Standard built-ins

Array.prototype.findLast()

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 element, or undefined if no match.

Formal Syntax & Structure

javascript syntaxjavascript
array.findLast(predicate, thisArg?)

Parameters & Attributes

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

Return Value

any

Matching element, or undefined if no match.

Working Example

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