Ramda.js R.equals() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Relation

Definition

Ramda’s R.equals() answers a value-equality question: are these two values equivalent by deep structure, not just reference? You pass two values and get back a Boolean. === is shallow and uses identity for objects. R.identical is Object.is — same reference, with special NaN and zero rules. R.equals walks arrays, objects, and nested data recursively, and handles cyclical structures safely. Many list helpers such as R.difference use equals internally for membership. Previous helper is R.eqBy. Next helper is R.gt for strict greater-than ordering.

The official samples cover the whole idea. R.equals(1, 1) is true. R.equals(1, ‘1’) is false — same as === on primitives with different types. R.equals([1, 2, 3], [1, 2, 3]) is true because contents match. Cyclical objects with a.v = a also compare as equal.

Syntax

Call R.equals. Start with this line.

Ramda
R.equals(a, b)
CallWhat it does
R.equals(a, b)Primary signature.
R.equals(...)Call the relation helper.

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

Library declarations
Ramda
R.equals(a, b)

Parameters

ParameterDescription
aRequired. Any. First value to compare. Not mutated.
bRequired. Any. Second value to compare. Not mutated.

Return Value

Return ValueDescription
Booleantrue when arguments are equivalent by value. false otherwise. Always a Boolean, never undefined.

Ramda Examples

📚 Getting Started

The official Ramda samples for primitives, arrays, and cyclical objects.

Example 1 — Official Primitives and Array Sample

Numbers, strings, and arrays from the Ramda docs. Same-type primitives match; cross-type does not. Arrays compare by value.

Ramda
R.equals(1, 1);
//=> true

R.equals(1, '1');
//=> false

R.equals([1, 2, 3], [1, 2, 3]);
//=> true
Try It Yourself

How It Works

That is the docs sample from ramdajs.com. 1 and 1 match. 1 and ‘1’ do not — same rule as === on primitives with different types. Two array literals with the same elements are equal by value even though references differ.

Example 2 — Official Cyclical Objects

Self-referencing objects a.v = a and b.v = b compare as equal without infinite recursion.

Ramda
const a = {};
a.v = a;
const b = {};
b.v = b;

R.equals(a, b);
//=> true
Try It Yourself

How It Works

Ramda tracks visited pairs to handle cycles. Both objects have one key v pointing back to themselves. The structures are equivalent, so R.equals returns true. Raw === would fail because a and b are different references.

📈 Practical Patterns

Contrast with reference equality, see equals inside list helpers, then reuse the curried form as a filter predicate.

Example 3 — vs R.identical and === on Cloned Objects

Two object literals with the same shape. Deep equality is true; reference checks are false.

Ramda
const a = { x: 1 };
const b = { x: 1 };

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

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

a === b;
//=> false
Try It Yourself

How It Works

R.equals walks both objects and finds matching contents. R.identical is Object.is — same reference only. === on objects also compares references. Use R.identical when you need the exact same instance in memory.

Example 4 — R.difference Uses Equals

Set subtraction uses R.equals for membership. Objects match by value, not reference.

Ramda
R.difference(
  [{ a: 1 }, { b: 2 }],
  [{ a: 1 }, { c: 3 }]
);
//=> [{ b: 2 }]
Try It Yourself

How It Works

{a:1} in the first list equals {a:1} in the second by value, so it is removed. {b:2} has no equal partner and stays. See also R.difference.

Example 5 — Curried Filter with R.equals(42)

Partial application fixes the first argument. The result is a one-argument predicate for R.filter.

Ramda
R.filter(R.equals(42), [41, 42, 42, 43]);
//=> [42, 42]
Try It Yourself

How It Works

R.equals(42) is a function waiting for a second value. R.filter passes each list element. Both 42 entries match by value and are kept.

Browser Support

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

✓ Ramda 0.15.0+ · Any JS runtime

Ramda.js R.equals()

Load Ramda 0.15.0 or later via CDN or npm, then call R.equals with two values. No extra browser API is required.

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

Bottom line: Safe in any project that includes Ramda 0.15.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.equals(a, b) returns true when two values are equivalent by deep value equality, false otherwise. Type: a → b → Boolean. Arity 2, curried. Added in v0.15.0.
R.equals(1, 1) is true. R.equals(1, '1') is false. R.equals([1, 2, 3], [1, 2, 3]) is true. Cyclical objects with a.v = a also compare as equal.
=== is shallow and uses reference identity for objects. R.equals walks structures recursively. {a:1} === {a:1} is false; R.equals says true.
R.identical is Object.is — same reference. NaN is identical to NaN, but +0 and -0 are not. R.equals treats +0 and -0 as equal and compares contents, not references.
Yes. Self-referencing objects such as a = {}; a.v = a compare correctly without infinite loops.
No. R.equals is a stable Ramda relation helper from v0.15.0. It is not deprecated, experimental, or non-standard.

Continue to R.gt() Method

Learn strict greater-than ordering with curried thresholds and R.__ placeholder patterns.

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