Ramda.js R.any() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.any(fn, list) answers one yes-or-no question: does at least one item pass the test? It returns true at the first item where the predicate fn passes, and false if none do (official Ramda docs). It is the curried, predicate-first version of Array.prototype.some.

Stable since v0.1.0: R.any is one of Ramda’s original list functions. It is not deprecated, experimental, or non-standard.

Syntax

Call R.any. Start with this line.

Ramda
R.any(fn, list) or R.any(fn)(list)
CallWhat it does
R.any(fn, list) or R.any(fn)(list)Primary signature.
R.any(...)Call the list helper.

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

Library declarations
Ramda
R.any(fn, list) or R.any(fn)(list)

Parameters

ParameterDescription
fnRequired. Predicate called with each item (no index); the result is treated as truthy or falsy
listRequired. Array to search — never changed

Return Value

Return ValueDescription
*true if some item passes, otherwise false

Ramda Examples

Example 1 — Official lessThan0 and lessThan2

No item is below 0, but one item is below 2 — the samples from the Ramda docs.

Ramda
const lessThan0 = R.flip(R.lt)(0);
const lessThan2 = R.flip(R.lt)(2);

console.log(R.any(lessThan0)([1, 2])); // false
console.log(R.any(lessThan2)([1, 2])); // true
Try It Yourself

How It Works

  1. Build the tests. R.lt(a, b) means a < b. R.flip swaps the first two arguments, so R.flip(R.lt)(2) is n => n < 2.
  2. Curry. R.any(lessThan0) waits for a list, so R.any(lessThan0)(list) equals R.any(lessThan0, list).
  3. No match. Neither 1 nor 2 is below 0, so the first result is false.
  4. One match. 1 < 2 is true, so the second result is true.

Example 2 — Empty List Is false

Nothing can pass an empty list. Compare it with R.all and R.none.

Ramda
const isNegative = n => n < 0;

console.log(R.any(isNegative, []));  // false
console.log(R.all(isNegative, []));  // true
console.log(R.none(isNegative, [])); // true
Try It Yourself

How It Works

  1. No items. The loop in R.any never runs, so it falls through to false — just like [].some(fn).
  2. all is the mirror. R.all finds no failing item, so it returns true.
  3. none is the opposite of any. R.none is !R.any, so it returns true.
  4. Takeaway. A false from R.any can simply mean the list was empty.

Example 3 — It Stops at the First Match

Record every item the predicate sees to watch the early exit.

Ramda
const checked = [];
const isEven = n => {
  checked.push(n);
  return n % 2 === 0;
};

console.log(R.any(isEven, [1, 3, 4, 5, 6])); // true
console.log(checked);                        // [1, 3, 4]
Try It Yourself

How It Works

  1. Track calls. isEven pushes each item into checked before testing it.
  2. Miss, miss. 1 and 3 are odd, so the search continues.
  3. Match. 4 is even, so R.any returns true immediately.
  4. Skipped. 5 and 6 are never checked — checked is [1, 3, 4].

Example 4 — Check a List of Objects

Does the team have an admin? Build the predicate with R.propEq.

Ramda
const isAdmin = R.propEq('admin', 'role');

const team = [
  { name: 'Ada', role: 'dev' },
  { name: 'Linus', role: 'admin' }
];
const guests = [{ name: 'Grace', role: 'guest' }];

console.log(R.any(isAdmin, team));   // true
console.log(R.any(isAdmin, guests)); // false
Try It Yourself

How It Works

  1. Build the test. R.propEq('admin', 'role') checks user.role === 'admin' (value first since Ramda v0.29).
  2. Search the team. Ada is a 'dev', so the search moves on.
  3. Match. Linus is an 'admin', so the first result is true.
  4. No match. The only guest is not an admin, so the second result is false.

Example 5 — A Reusable Checker with R.reject

Leave out the list to get a named function, then drop every form that has a blank field.

Ramda
const hasBlank = R.any(R.isEmpty);

const forms = [
  ['Ada', '[email protected]'],
  ['Linus', ''],
  ['', '[email protected]']
];

console.log(R.reject(hasBlank, forms)); // [['Ada', '[email protected]']]
console.log(hasBlank(['Linus', '']));   // true
Try It Yourself

How It Works

  1. Curry. R.any(R.isEmpty) has no list yet, so hasBlank is a function waiting for one.
  2. Test a field. R.isEmpty('') is true, so any form with an empty string matches.
  3. Reject. R.reject removes every form where hasBlank returns true.
  4. Result. Only Ada’s form has no blank field, so it is the only one left.

Browser & Runtime Support

R.any() is plain JavaScript inside Ramda (available since v0.1.0). It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.any()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import. The arrow functions in some examples need an ES2015+ engine, which every modern browser has.

100% With Ramda loaded
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.any() Universal

Bottom line: Safe in any project that includes Ramda. Example 4 uses the value-first R.propEq order, which needs Ramda 0.29.0 or later. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected] from jsDelivr.

Frequently Asked Questions

R.any(fn, list) returns true as soon as one item in the list passes the predicate fn, and false if no item passes. Official sample: with lessThan2 = R.flip(R.lt)(2), R.any(lessThan2)([1, 2]) is true because 1 < 2.
There is no item that could pass, so 'at least one item passes' is false. Native [].some(fn) also returns false. This is the mirror of R.all, which returns true for an empty list.
R.any needs at least one item to pass. R.all needs every item to pass. R.none needs zero items to pass, so R.none(fn, list) is the same as !R.any(fn, list). For lessThan2 on [1, 2]: any is true, all is false, none is false.
Yes. It checks items from left to right and returns true at the first item whose predicate result is truthy. Items after that are never checked.
Use R.includes(value, list) when you only want to know whether a value is in the list; it compares with R.equals. Use R.any when you need a custom test, such as 'any price above 100' or 'any user with role admin'.
No. R.any has been a stable Ramda list function since v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.aperture()

Split a list into sliding windows of consecutive items.

R.aperture() 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