Ramda.js R.eqBy() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Relation

Definition

Ramda’s R.eqBy() answers a projection question: after you map both values with f, are the results equal in R.equals terms? You pass a unary function, then two values. You get back a Boolean. R.equals(x, y) compares whole values. R.eqProps('id', x, y) compares one object key. eqBy is the general form: any projection function, any type. The same projection idea powers R.uniqBy for dedupe and pairs naturally with R.differenceWith when you need a reusable comparator. Previous helper is R.differenceWith. Next helper is R.equals.

The official sample is the whole idea. R.eqBy(Math.abs, 5, -5) is true because both sides map to 5. In app code, eqBy(R.prop('id')) is the usual user-id comparator: same database id, different display name, still a match. eqBy(R.toLower) gives case-insensitive string comparison on the projection.

Syntax

Call R.eqBy. Start with this line.

Ramda
R.eqBy(f, x, y)
CallWhat it does
R.eqBy(f, x, y)Primary signature.
R.eqBy(...)Call the relation helper.

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

Library declarations
Ramda
R.eqBy(f, x, y)

Parameters

ParameterDescription
fRequired. Function. A unary projection. Applied to both x and y before comparison.
xRequired. Any. First value to compare. Not mutated.
yRequired. Any. Second value to compare. Not mutated.

Return Value

Return ValueDescription
Booleantrue when R.equals(f(x), f(y)). false otherwise. Always a Boolean, never undefined.

Ramda Examples

📚 Getting Started

The official Ramda sample and the usual user-id comparator pattern.

Example 1 — Official Math.abs Sample

Apply Math.abs to both sides, then R.equals. Five and negative five map to the same magnitude.

Ramda
R.eqBy(Math.abs, 5, -5);
//=> true
Try It Yourself

How It Works

That is the docs sample from ramdajs.com. f(5) and f(-5) both become 5. R.equals on those mapped values returns true. Raw === on 5 and -5 would be false.

Example 2 — R.eqBy(R.prop('id')) on Users

Same id, different name strings. The projection ignores everything except the id field.

Ramda
const byId = R.eqBy(R.prop('id'));
const ada = { id: 1, name: 'Ada' };
const alsoAda = { id: 1, name: 'Augusta' };

byId(ada, alsoAda);
//=> true
Try It Yourself

How It Works

R.prop('id') extracts the id from each user. eqBy compares those extracted values with R.equals. This is the most common real-world pattern: treat records as equal when their stable identifier matches.

📈 Practical Patterns

Contrast with cousins, compare strings case-insensitively, then reuse the curried comparator in a list helper.

Example 3 — vs R.equals and vs R.eqProps

Two records share an id but differ on name. Full equality is false; id-based tests are true.

Ramda
const a = { id: 7, name: 'Alpha' };
const b = { id: 7, name: 'Beta' };

R.equals(a, b);
//=> false

R.eqProps('id', a, b);
//=> true

R.eqBy(R.prop('id'), a, b);
//=> true
Try It Yourself

How It Works

R.equals walks the whole object shape. R.eqProps('id') and eqBy(R.prop('id')) agree on this pair because only the id projection matters. For one object key, pick whichever API reads clearer in your codebase.

Example 4 — R.eqBy(R.toLower, 'Hello', 'hello')

Project both strings to lowercase before comparing. Casing differences disappear in the mapped values.

Ramda
R.eqBy(R.toLower, 'Hello', 'hello');
//=> true
Try It Yourself

How It Works

R.toLower('Hello') and R.toLower('hello') both become 'hello'. R.equals on those strings returns true. Raw string equality would fail because of the capital H.

Example 5 — Curried Leftover with differenceWith

Fill the projection once. Pass the resulting pair predicate to R.differenceWith to subtract users by id.

Ramda
const list1 = [
  { id: 1, name: 'Ada' },
  { id: 2, name: 'Grace' },
  { id: 3, name: 'Alan' }
];
const list2 = [{ id: 2, name: 'whoever' }];

R.differenceWith(R.eqBy(R.prop('id')), list1, list2);
//=> [{ id: 1, name: 'Ada' }, { id: 3, name: 'Alan' }]
Try It Yourself

How It Works

R.eqBy(R.prop('id')) is already a two-argument predicate. differenceWith uses it for membership and leftover uniqueness. Grace drops because id 2 appears in list2, even though the name string differs. See also R.differenceWith.

Browser Support

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

✓ Ramda 0.18.0+ · Any JS runtime

Ramda.js R.eqBy()

Load Ramda 0.18.0 or later via CDN or npm, then call R.eqBy with a projection function and two values. No extra browser API is required.

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

Bottom line: Safe in any project that includes Ramda 0.18.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.eqBy(f, x, y) returns true when f(x) and f(y) are equal in R.equals terms. Type: (a → b) → a → a → Boolean. Arity 3, curried. Added in v0.18.0.
R.eqBy(Math.abs, 5, -5) is true. Math.abs maps both sides to 5, and R.equals says they match.
R.equals compares whole values. R.eqBy compares only what f projects: ids, lowercase strings, absolute values, or any mapped key.
eqProps compares one object property on two records. eqBy takes any unary function f and works on any type, not just objects with a named key.
R.eqBy(R.prop('id')) is a two-argument pair test ready for R.differenceWith, R.uniqWith, and R.groupWith. R.eqBy(R.toLower) compares strings case-insensitively.
No. R.eqBy is a stable Ramda relation helper from v0.18.0. It is not deprecated, experimental, or non-standard.

Continue to R.equals()

Learn deep whole-value equality — the foundation behind eqBy and many list helpers.

R.equals() Method →

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