Ramda.js R.whereEq() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Ramda’s R.whereEq() answers a spec question: does this object hold the same values as this spec, in R.equals terms? You pass a spec of values, then the test object. You get a boolean. Extra keys on the test object do not matter. A missing spec key is undefined, so it only matches if the spec leftover equals undefined. Native JavaScript would write several === checks. whereEq names those checks once, uses deep equality, stays data-last, and curries, so R.whereEq(spec) is already a function of one object — ready for R.filter and R.find.

The official sample is the whole idea. The spec is {a: 1, b: 2}. A row with only a fails. A row with both keys passes. A row with extra c still passes. A row whose b is 1 fails. Need ranges or complements? That is R.where. Need any one field to match? That is R.whereAny. Need one key versus a constant? That is R.propEq. Previous Object helper is R.whereAny. This is the last helper in Ramda’s Object category.

Syntax

Call R.whereEq. Start with this line.

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

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

Library declarations
Ramda
R.whereEq(spec, testObj)

Parameters

ParameterDescription
specRequired. Object. Own properties are expected leftovers. Each is compared with testObj[key] via R.equals. Inherited spec keys are skipped because R.map walks...
testObjRequired. Object. The record under test. Extra keys are ignored. A missing spec key reads as undefined.

Return Value

Return ValueDescription
Booleantrue when every own spec leftover equals the matching test field. Otherwise false. Neither object is mutated. An empty spec yields true.

Ramda Examples

📚 Getting Started

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

Example 1 — Official pred

Every spec leftover must equal the matching field. Extra keys would be ignored. One mismatch is enough to yield false.

Ramda
const pred = R.whereEq({a: 1, b: 2});

pred({a: 1});
//=> false

pred({a: 1, b: 2});
//=> true

pred({a: 1, b: 2, c: 3});
//=> true

pred({a: 1, b: 1});
//=> false
Try It Yourself

How It Works

The spec asks for a: 1 and b: 2. A missing b is undefined, so row 1 fails. Extra c is ignored, so row 3 still passes. That is the docs sample from ramdajs.com.

Example 2 — vs where, whereAny, and propEq

Same row. whereEq and where are AND. whereAny is OR. propEq tests one key against a constant.

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

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

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

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

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

How It Works

extra is ignored. whereEq and where agree here because wrapping values in R.equals is exactly what whereEq does. whereAny is true because b matches even though a does not. In Ramda 0.30, propEq is value then name.

📈 Practical Patterns

Extra keys, missing fields, nested R.equals, then filter and find, then why a function leftover is not called.

Example 3 — Extra Keys, Missing Keys, Nested Equals

Extra fields do not fail the spec. A missing field is undefined. Nested leftovers match by value. An empty spec never loops, so the leftover is true.

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

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

R.whereEq({ meta: { ok: true } }, { meta: { ok: true } });
//=> true

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

How It Works

R.equals({ ok: true }, { ok: true }) is true even when the nested objects are different references. R.whereEq({}, null) is also true, because the mapped spec is empty and where never reads the test object. A non-empty spec on null throws.

Example 4 — Curry, Filter, and Find

Fill the spec to get a predicate of one row. Keep matching tickets. Find the first match.

Ramda
const pred = R.whereEq({
  status: 'open',
  team: 'blue'
});

const rows = [
  { id: 1, status: 'open', team: 'blue' },
  { id: 2, status: 'done', team: 'blue' },
  { id: 3, status: 'open', team: 'red' }
];

R.filter(pred, rows);
//=> [{ id: 1, status: 'open', team: 'blue' }]

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

How It Works

Because whereEq is arity 2, filling spec leaves a function of one object for R.filter and R.find. Row 2 fails status. Row 3 fails team. That is the docs use case: declarative constraints for list helpers.

Example 5 — Functions Belong on where

A function leftover is compared with R.equals, not called. Ranges and complements belong on where.

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

R.where({ score: R.gt(R.__, 10) }, { score: 11 });
//=> true

R.whereEq({ score: R.gt(R.__, 10) }, { score: 11 });
//=> false
Try It Yourself

How It Works

whereEq maps each leftover through R.equals, then calls where. A function leftover becomes R.equals(fn), which compares the function to 11 and yields false. Use R.where when the leftover must run.

Browser Support

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

✓ Ramda 0.14.0+ · Any JS runtime

Ramda.js R.whereEq()

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

100% With Ramda 0.14.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.whereEq() Universal

Bottom line: Safe in any project that includes Ramda 0.14.0 or later. 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.whereEq(spec, testObj) returns true when every own spec key matches testObj of that same key in R.equals terms. Extra keys on the test object are ignored. It is where after mapping each spec leftover through R.equals. Added in v0.14.0.
const pred = R.whereEq({ a: 1, b: 2 }). pred({a:1}) is false. pred({a:1, b:2}) is true. pred({a:1, b:2, c:3}) is true. pred({a:1, b:1}) is false.
whereEq compares spec values with R.equals (AND). where runs predicate functions (AND). whereAny runs predicate functions but needs only one pass (OR).
That field is undefined, so it matches only if the spec leftover equals undefined. R.whereEq({ a: 1 }, {}) is false. An empty spec {} returns true, even for null, because no keys need to match.
You can, but they are compared with R.equals, not called. R.whereEq({ score: R.gt(R.__, 10) }, { score: 11 }) is false. Use R.where when leftovers must be predicates.
No. R.whereEq is a stable Ramda object helper from v0.14.0. It is not deprecated, experimental, or non-standard.

Continue to R.allPass()

Learn how to AND a list of predicates using Ramda R.allPass().

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