Ramda’s R.eqProps() answers a one-key question: do these two objects agree on this property? You pass the key, then the first object, then the second. You get a boolean. Other keys do not matter. The comparison is R.equals, not ===, so nested objects and arrays match by structure.
The official sample is the whole idea. Two objects share c: 3 but differ on a. Native JavaScript would write o1.a === o2.a, which fails for nested values and for NaN. eqProps names the key once, stays data-last, and curries, so R.eqProps('id') is already a function of two objects — ready for R.uniqWith. One object versus a constant? That is R.propEq. Whole values? That is R.equals. Lodash _.matchesProperty is closer to propEq (value + path on one object).
Syntax
Call R.eqProps. Start with this line.
Ramda
R.eqProps(prop, obj1, obj2)
Call
What it does
R.eqProps(prop, obj1, obj2)
Primary signature.
R.eqProps(...)
Call the object helper.
Prefer import { eqProps } from "ramda" when you want a named import.
Library declarations
Ramda
R.eqProps(prop, obj1, obj2)
Parameters
Parameter
Description
prop
Required. String (or key). The property name to read on both objects. Prototype properties are included, because the source uses obj[prop].
obj1
Required. Object. The first record. A missing key reads as undefined.
obj2
Required. Object. The second record. Compared with obj1[prop] via R.equals.
Return Value
Return Value
Description
Boolean
true when the two property values are equal in R.equals terms. Otherwise false. Neither object is mutated.
Ramda Examples
📚 Getting Started
The official Ramda sample, then the same helper on nested values so you can see R.equals.
Example 1 — Official Property Compare
Only the named key is compared. Other fields can differ and still yield true.
o1.a is 1 and o2.a is 10, so 'a' is false. Both objects hold c: 3, so 'c' is true even though b and d differ. That is the docs sample from ramdajs.com.
Example 2 — R.equals, Not ===
Nested arrays and objects match by value. The nested references are different. NaN equals NaN.
The source is equals(obj1[prop], obj2[prop]). R.equals walks nested objects and treats NaN as equal to itself. Native === would be false for both the nested meta objects and for NaN.
📈 Practical Patterns
Missing keys, inherited properties, then a curried helper for filter and uniqWith, then the cousins propEq and equals.
Example 3 — Missing Keys and Prototypes
Two missing properties are both undefined, so the result is true. One missing is false. Inherited keys are read.
There is no hasOwnProperty check. {}['z'] is undefined on both sides, and R.equals(undefined, undefined) is true. Object.create still exposes role through the prototype chain, so that compare succeeds.
Example 4 — Curry, Filter, uniqWith
Fill the key (and maybe one object) to get a predicate. Map it with filter. Pass the two-object form to uniqWith.
Because eqProps is arity 3, filling prop and obj1 leaves a function of one object for R.filter. Filling only prop leaves a function of two objects for R.uniqWith. uniqWith keeps the first row of each equal pair.
Example 5 — propEq vs equals
propEq pins a value on one object. eqProps compares two objects. equals compares the whole record.
In Ramda 0.30, R.propEq is (val, name, obj) — value first. Use it when you already have the number or string. Use eqProps when both sides are objects. Use R.equals when every key must match.
Compatibility
Browser Support
R.eqProps() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.1.0+ · Any JS runtime
Ramda.js R.eqProps()
Load Ramda 0.1.0 or later via CDN or npm, then call R.eqProps with a key and two objects. No extra browser API is required.
100%With Ramda 0.1.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.eqProps()Universal
Bottom line: Safe in any project that includes Ramda 0.1.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.eqProps(prop, obj1, obj2) returns true when obj1[prop] and obj2[prop] are equal in R.equals terms. Other keys are ignored. Added in v0.1.0.
With o1 = {a:1, b:2, c:3, d:4} and o2 = {a:10, b:20, c:3, d:40}, R.eqProps('a', o1, o2) is false and R.eqProps('c', o1, o2) is true.
It uses R.equals. Nested objects and arrays match by value. NaN equals NaN. Two missing properties are both undefined, so the result is true.
propEq compares one object to a given value (value first in Ramda 0.30). eqProps compares the same key on two objects. equals compares whole values, not one property.
Arity 3 means R.eqProps('id') is a function of two objects, ready for R.uniqWith. R.eqProps('id', someUser) is a function of one object, ready for R.filter.
No. R.eqProps is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.