Ramda.js R.find() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

A helper that returns the first item in a list that passes a test. If no item passes, it returns undefined. It stops checking as soon as it finds a match, and it never changes the list. It has been part of Ramda List since v0.1.0 (stable, not deprecated, experimental, or non-standard).

Why not the native method? You have to call Array.prototype.find on the data. R.find(isAdmin) is curried and data-last, so it becomes a reusable lookup step for R.pipe.

Syntax

Call R.find. Start with this line.

Ramda
R.find(pred, list)
CallWhat it does
R.find(pred, list)Primary signature.
R.find(...)Call the list helper.

Prefer import { find } from "ramda" when you want a named import.

Library declarations
Ramda
R.find(pred, list)

Parameters

ParameterDescription
predRequired. value → Boolean. Truthy means "this is the one"
listRequired. An array (or string), or any object with its own find method

Return Value

Return ValueDescription
*The first passing item itself (not a copy), or undefined

Ramda Examples

Example 1 — Official Hit and Miss

Look for a: 2, then for a: 4, which is not in the list.

Ramda
const xs = [{ a: 1 }, { a: 2 }, { a: 3 }];

console.log(R.find(R.propEq(2, "a"))(xs));
// → { a: 2 }

console.log(R.find(R.propEq(4, "a"))(xs));
// → undefined
Try It Yourself

How It Works

  1. Build the test. R.propEq(2, "a") returns obj => obj.a equals 2.
  2. Curried call. R.find(test) waits for a list, and (xs) supplies it.
  3. Hit. {a: 1} fails, {a: 2} passes, so {a: 2} is returned and {a: 3} is never checked.
  4. Miss. No object has a: 4, so the result is undefined. It is not [] or -1.

Example 2 — Look Up a Record by Property

Find a user by id, then find the first editor’s name.

Ramda
const users = [
  { id: 1, name: "Ada", role: "admin" },
  { id: 2, name: "Lin", role: "editor" },
  { id: 3, name: "Bo",  role: "editor" }
];

console.log(R.find(R.propEq(2, "id"), users));
// → { id: 2, name: "Lin", role: "editor" }

const firstEditor = R.find(R.propEq("editor", "role"), users);
console.log(firstEditor.name);
// → Lin
Try It Yourself

How It Works

  1. Argument order. Since Ramda v0.29, R.propEq takes the value first and then the property name.
  2. By id. Only user 2 has id: 2, so that whole object comes back.
  3. First of many. Lin and Bo are both editors. R.find returns Lin because she comes first.
  4. Read a field. .name is safe here because we know an editor exists. In real code, guard against undefined first.

Example 3 — Several Rules with R.where

Find the first product that is in stock and costs under 20.

Ramda
const products = [
  { name: "Pen",  price: 2,  stock: 0 },
  { name: "Book", price: 15, stock: 0 },
  { name: "Bag",  price: 40, stock: 3 },
  { name: "Cap",  price: 12, stock: 5 }
];

const cheapInStock = R.where({
  stock: s => s > 0,
  price: p => p < 20
});

console.log(R.find(cheapInStock, products));
// → { name: "Cap", price: 12, stock: 5 }
Try It Yourself

How It Works

  1. One rule per field. R.where passes only when every field test passes.
  2. Pen and Book. Both are cheap, but stock is 0, so they fail.
  3. Bag. It is in stock, but 40 is not under 20, so it fails.
  4. Cap. Both rules pass. R.find returns Cap and stops there.

Example 4 — find vs filter

Same test, same list. One returns a single item and the other returns every match.

Ramda
const files = ["notes.txt", "data.csv", "report.csv"];
const isCsv = R.endsWith(".csv");

console.log(R.find(isCsv, files));
// → data.csv

console.log(R.filter(isCsv, files));
// → ["data.csv", "report.csv"]
Try It Yourself

How It Works

  1. Ready-made test. R.endsWith(".csv") is already a one-argument predicate.
  2. find. It skips notes.txt, matches data.csv, and stops. You get a string.
  3. filter. It checks all three names and keeps both CSVs. You get an array.
  4. Rule of thumb. Use find when you want one item and filter when you want all of them.

Example 5 — Safe Default in a Pipeline

Build a reusable lookup that never returns undefined.

Ramda
const firstPdf = R.pipe(
  R.find(R.endsWith(".pdf")),
  R.defaultTo("no pdf")
);

console.log(firstPdf(["notes.txt", "guide.pdf"]));
// → guide.pdf

console.log(firstPdf(["data.csv"]));
// → no pdf
Try It Yourself

How It Works

  1. Curried step. R.find(R.endsWith(".pdf")) has its test but no list yet.
  2. Pipe. R.pipe runs the lookup first, then passes its result to the next step.
  3. Fallback. R.defaultTo("no pdf") replaces undefined (or null/NaN) and passes real values through.
  4. Result. The first list has a PDF, so you get guide.pdf. The second has none, so you get no pdf.

Browser & Runtime Support

R.find is one of Ramda’s original List helpers, available since v0.1.0. It uses its own loop rather than the ES2015 Array.prototype.find, so it runs anywhere Ramda runs. In the browser, load it from a CDN or a bundler. In Node.js, Bun, or Deno, run npm install ramda.

✓ Stable · Ramda 0.1.0+

R.find()

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 Chrome Modern versions · Desktop & Mobile
Full support
Mozilla Firefox Modern versions · Desktop & Mobile
Full support
Apple Safari Modern versions · macOS & iOS
Full support
Microsoft Edge Chromium-based
Full support
Opera Modern versions
Full support
Samsung Internet Modern versions · Android
Full support
Android WebView Modern WebView
Full support
Internet Explorer Not a target for current Ramda releases
Legacy
Node.js Maintained LTS · npm install ramda
Supported
Bun import from "ramda"
Supported
Deno import from "npm:ramda"
Supported
R.find Ramda 0.1.0+

Bottom line: Safe for production in any modern browser or JavaScript runtime once Ramda is loaded. The labs on this page use [email protected] from a CDN.

Frequently Asked Questions

R.find(pred, list) returns the first item for which pred returns a truthy value, or undefined if no item passes. It stops checking as soon as it finds a match. Docs sample: R.find(R.propEq(2, 'a'))([{a: 1}, {a: 2}, {a: 3}]) //=> {a: 2}.
Both return the first match or undefined. R.find is curried and data-last, so R.find(isAdmin) is a reusable function for R.pipe. Its predicate receives only the value, with no index or array argument.
R.find returns one item (or undefined) and stops at the first match. R.filter always returns a new array with every match. Use find for lookups and filter for subsets.
Wrap the result with R.defaultTo: R.defaultTo('none', R.find(pred, list)). In a pipeline: R.pipe(R.find(pred), R.defaultTo('none')).
A found item can be falsy, such as 0, an empty string, or false, so if (result) treats it as a miss. Compare with result !== undefined, or use R.findIndex and check for -1.
No. R.find has been part of Ramda since v0.1.0 and is stable. It is not deprecated, experimental, or non-standard.

Next: R.findIndex()

Learn how to get the position of the first item that passes a test.

R.findIndex() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful