Ramda.js R.whereAny() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.whereAny() answers a spec question: does this object pass at least one named predicate? You pass a spec object whose own values are functions, then the test object. You get a boolean. Extra keys on the test object do not matter. A missing spec key is still tested, with undefined. Native JavaScript would write several if checks joined with ||. whereAny names those checks once, stays data-last, and curries, so R.whereAny(spec) is already a function of one object — ready for R.filter and R.find.

The official sample is the whole idea. Four predicates sit on the spec: a equals 'foo', b is not 'xxx', x is greater than 10, y is less than 20. One true leftover is enough. The first docs row has a failed x and y, but a still matches, so the leftover is true. Need every predicate to pass? That is R.where. Need literals instead of functions? That is R.whereEq. Need one key only? That is R.propSatisfies. Previous Object helper is R.where. Next is R.whereEq.

Syntax

Call R.whereAny. Start with this line.

Ramda
R.whereAny(spec, testObj)
CallWhat it does
R.whereAny(spec, testObj)Primary signature.
R.whereAny(...)Call the object helper.

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

Library declarations
Ramda
R.whereAny(spec, testObj)

Parameters

ParameterDescription
specRequired. Object. Own properties must be predicate functions. Each is called with testObj[key]. Inherited spec keys are skipped.
testObjRequired. Object. The record under test. Extra keys are ignored. A missing spec key reads as undefined.

Return Value

Return ValueDescription
Booleantrue when any own spec predicate returns a truthy leftover. Otherwise false. Neither object is mutated. An empty spec yields false.

Ramda Examples

📚 Getting Started

The official Ramda object sample, then the same idea compared with where and whereEq.

Example 1 — Official pred

One true leftover is enough. Extra keys would be ignored. Every field can fail except one.

Ramda
const pred = R.whereAny({
  a: R.equals('foo'),
  b: R.complement(R.equals('xxx')),
  x: R.gt(R.__, 10),
  y: R.lt(R.__, 20)
});

pred({a: 'foo', b: 'xxx', x: 8, y: 34});
//=> true

pred({a: 'xxx', b: 'xxx', x: 9, y: 21});
//=> false

pred({a: 'bar', b: 'xxx', x: 10, y: 20});
//=> false

pred({a: 'foo', b: 'bar', x: 10, y: 20});
//=> true

pred({a: 'foo', b: 'xxx', x: 11, y: 20});
//=> true
Try It Yourself

How It Works

b: R.complement(R.equals('xxx')) means b must not be 'xxx'. The first row still passes because a is 'foo', even though x and y fail. Rows 2 and 3 miss every test. That is the docs sample from ramdajs.com.

Example 2 — vs where, whereEq, and propSatisfies

Same row. whereAny is OR. where is AND. whereEq uses literals. propSatisfies tests one key.

Ramda
const row = { a: 1, b: 9, extra: true };

R.whereAny({ a: R.equals(1), b: R.equals(2) }, row);
//=> true

R.where({ a: R.equals(1), b: R.equals(2) }, row);
//=> false

R.whereEq({ a: 1, b: 2 }, row);
//=> false

R.propSatisfies(R.equals(1), 'a', row);
//=> true
Try It Yourself

How It Works

extra is ignored. whereAny is true because a matches even though b does not. where and whereEq need both keys. Prefer where when every leftover must pass.

📈 Practical Patterns

Extra keys, missing fields, an empty spec that yields false, then filter and find, then why literals still throw.

Example 3 — Extra Keys, Missing Keys, Empty Spec

Extra fields do not fail the spec. A missing field still runs the predicate with undefined. An empty spec never loops, so the leftover is false — the opposite of R.where.

Ramda
const anyPass = R.whereAny({
  age: R.gte(R.__, 18),
  vip: R.equals(true)
});

anyPass({ name: 'Ada', age: 21 });
//=> true

anyPass({ name: 'Ada', vip: true });
//=> true

anyPass({ name: 'Ada' });
//=> false

R.whereAny({}, { x: 1 });
//=> false
Try It Yourself

How It Works

Age 21 passes the age test. A vip flag passes without an age. A missing age and vip both yield undefined, so both predicates fail. R.whereAny({}, null) is also false, because the loop never finds a true leftover. A non-empty spec on null throws.

Example 4 — Curry, Filter, and Find

Fill the spec to get a predicate of one row. Keep tickets that are open or high-scoring. Find the first match.

Ramda
const pred = R.whereAny({
  status: R.equals('open'),
  score: R.gt(R.__, 10)
});

const rows = [
  { id: 1, status: 'open', score: 4 },
  { id: 2, status: 'done', score: 20 },
  { id: 3, status: 'done', score: 4 }
];

R.filter(pred, rows);
//=> [{ id: 1, status: 'open', score: 4 }, { id: 2, status: 'done', score: 20 }]

R.find(pred, rows);
//=> { id: 1, status: 'open', score: 4 }
Try It Yourself

How It Works

Because whereAny is arity 2, filling spec leaves a function of one object for R.filter and R.find. Row 1 matches status. Row 2 matches score. Row 3 matches neither. That is the docs use case: declarative OR constraints for list helpers.

Example 5 — Literals Still Throw

A number in the spec is not a predicate. Wrap it with R.equals. There is no whereAnyEq.

Ramda
R.whereAny({ a: R.equals(1) }, { a: 1 });
//=> true

R.where({ a: R.equals(1), b: R.equals(2) }, { a: 1, b: 9 });
//=> false

typeof 1 === 'function';
//=> false
Try It Yourself

How It Works

Spec values must still be functions. R.whereAny({ a: 1 }, { a: 1 }) throws because 1 is not callable. The second line shows AND: where needs both keys. Wrap literals with R.equals. There is no whereAnyEq helper.

Browser Support

R.whereAny() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.28.0+ · Any JS runtime

Ramda.js R.whereAny()

Load Ramda 0.28.0 or later via CDN or npm, then call R.whereAny with a spec of predicates and a test object. No extra browser API is required.

100% With Ramda 0.28.0+
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.whereAny() Universal

Bottom line: Safe in any project that includes Ramda 0.28.0 or later. Spec values must be functions. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].

Frequently Asked Questions

R.whereAny(spec, testObj) returns true when at least one own spec property is a predicate that returns true for testObj of that same key. Extra keys on the test object are ignored. Added in v0.28.0.
const pred = R.whereAny({ a: R.equals('foo'), b: R.complement(R.equals('xxx')), x: R.gt(R.__, 10), y: R.lt(R.__, 20) }). pred({a:'foo', b:'xxx', x:8, y:34}) is true because a matches. The two all-miss rows are false. The last two official rows are true.
whereAny is OR: one passing predicate is enough. where is AND: every predicate must pass. whereEq compares spec values with R.equals instead of calling functions.
The predicate still runs, with undefined. That leftover is rarely true, so a missing key usually does not count as a pass. An empty spec {} returns false, even for null, because no predicate ever succeeds.
No. Spec values must be functions. R.whereAny({ a: 1 }, { a: 1 }) throws because 1 is not callable. Wrap with R.equals, or use R.whereEq when every leftover is a value and you need AND.
No. R.whereAny is a stable Ramda object helper from v0.28.0. It is not deprecated, experimental, or non-standard.

Continue to R.whereEq()

Learn how to match spec values with R.equals using Ramda R.whereEq().

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