A helper that searches a list from the right and returns the last item that passes a test. If no item passes, it returns undefined. It stops at the first match it meets (which is the last one in the list) and never changes the list. It has been part of Ramda List since v0.1.1 (stable, not deprecated, experimental, or non-standard).
Why not the native method?Array.prototype.findLast only arrived in ES2023, and you have to call it on the data. R.findLast(isError) works in older engines too, and it is curried, so it slots straight into R.pipe.
Syntax
Call R.findLast. Start with this line.
Ramda
R.findLast(pred, list)
Call
What it does
R.findLast(pred, list)
Primary signature.
R.findLast(...)
Call the list helper.
Prefer import { findLast } from "ramda" when you want a named import.
Library declarations
Ramda
R.findLast(pred, list)
Parameters
Parameter
Description
pred
Required. value → Boolean. Truthy means "this is the one"
list
Required. An array (or string) to search
Return Value
Return Value
Description
*
The last passing item itself (not a copy), or undefined
Ramda Examples
Example 1 — Official Samples vs R.find
Two objects match. findLast and find return different ones.
Result. The newest error is network down. The info-only list has no errors, so you get none.
Compatibility
Browser & Runtime Support
R.findLast has been a Ramda List helper since v0.1.1. It uses its own backward loop, so it does not need the ES2023 Array.prototype.findLast (Chrome 97+, Firefox 104+, Safari 15.4+, Node.js 18+). It runs anywhere Ramda runs.
✓ Stable · Ramda 0.1.1+
R.findLast()
Support depends on the Ramda version you load, not on a browser feature. Your own test must also be valid in that runtime. For example, arrow functions need an ES2015 engine.
100%Modern browsers & runtimes
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeChromium-based
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Android WebViewModern WebView
Full support
Internet ExplorerNot a target for current Ramda releases
Legacy
Node.jsMaintained LTS · npm install ramda
Supported
Bunimport from "ramda"
Supported
Denoimport from "npm:ramda"
Supported
R.findLastRamda 0.1.1+
Bottom line: Safe for production in any modern browser or JavaScript runtime once Ramda is loaded, including engines that predate the native findLast. The labs on this page use [email protected] from a CDN.
Frequently Asked Questions
R.findLast(pred, list) searches from the right and returns the last item for which pred returns a truthy value, or undefined if no item passes. Docs sample: with xs = [{a: 1, b: 0}, {a: 1, b: 1}], R.findLast(R.propEq(1, 'a'))(xs) //=> {a: 1, b: 1}.
Both return one matching item or undefined. R.find scans left to right and returns the first match. R.findLast scans right to left and returns the last match. They only differ when more than one item passes.
Both return the last match or undefined. The native method arrived in ES2023 (Chrome 97, Firefox 104, Safari 15.4, Node.js 18), while R.findLast works in any engine Ramda supports. It is also curried and data-last, so R.findLast(pred) is reusable in R.pipe.
undefined, both for an empty list and when no item passes. Add a fallback with R.defaultTo or R.propOr if you need a value.
R.addIndex counts calls, starting at 0. R.findLast calls the test from the right, so the last item is labelled index 0. Use R.findLastIndex when you need the real position.
No. R.findLast has been part of Ramda since v0.1.1 and is stable. It is not deprecated, experimental, or non-standard.