JavaScript Array.prototype.findLast() Method
The findLast() method searches an array from the end and returns the last element that passes a test.
Description
The findLast() method works like find(), but searches backwards from the last element and returns the first match it finds, which is the last matching element in the array. It returns undefined if nothing matches.
It's handy for things like the most recent log entry of a certain type, without having to reverse a copy of the array first.
It was added in 2023 together with findLastIndex() and is supported in all current browsers. Before that, the usual approach was [...arr].reverse().find(...), which creates a copy of the array; findLast() avoids the copy and makes the intent clearer. As with find(), it stops as soon as it finds a match.
Syntax
array.findLast(callbackFn)
array.findLast(callbackFn, thisArg)Parameters
- callbackFnA function called for each element, receiving
element,indexandarray. - thisArgOptional. A value to use as
thisinsidecallbackFn.
Return Value
The last element that passes the test, or undefined if none does.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.findLast() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





