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)
Call
What 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
Parameter
Description
f
Required. Function. A unary projection. Applied to both x and y before comparison.
x
Required. Any. First value to compare. Not mutated.
y
Required. Any. Second value to compare. Not mutated.
Return Value
Return Value
Description
Boolean
true 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.
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.
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
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.
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.
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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll 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.