Ramda.js R.innerJoin() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Relation

Definition

Ramda’s R.innerJoin() answers a cross-list matching question: which elements of xs pair with at least one element of ys according to pred? You pass a binary predicate and two lists and get back a filtered sublist of xs. It is not same-type set intersection like R.intersection, and not a single-list filter like R.filter unless you bake ys into the predicate yourself. Result order follows xs; duplicates from xs are kept. Previous helper is R.identical. Next is R.intersection for same-type deduped overlap with R.equals.

The official sample joins band-member records against an id list. R.innerJoin((record, id) => record.id === id, records, [177, 456, 999]) returns Stephen Stills and Neil Young — the records whose id appears in the second list. Ids with no matching record (like 999) are ignored. Records with no matching id are dropped from the result.

Syntax

Call R.innerJoin. Start with this line.

Ramda
R.innerJoin(pred, xs, ys)
CallWhat it does
R.innerJoin(pred, xs, ys)Primary signature.
R.innerJoin(...)Call the relation helper.

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

Library declarations
Ramda
R.innerJoin(pred, xs, ys)

Parameters

ParameterDescription
predRequired. (a, b) → Boolean. Binary predicate — receives one element from xs and one from ys. Returns whether they match.
xsRequired. [a]. First list — elements to filter. Order and duplicates in the result come from this list. Not mutated.
ysRequired. [b]. Second list — membership source. An xs element is kept when pred(x, y) is true for any y in ys. Not mutated.

Return Value

Return ValueDescription
[a]xs' — each element of xs that matches one or more elements of ys according to pred. Preserves xs order. Duplicates from xs are not removed.

Ramda Examples

📚 Getting Started

The official Ramda records-and-ids sample and how it differs from same-type intersection.

Example 1 — Official Records + Id List Sample

Filter band-member records to those whose id appears in a plain id list. Result order follows the records list.

Ramda
R.innerJoin(
  (record, id) => record.id === id,
  [{id: 824, name: 'Richie Furay'},
   {id: 956, name: 'Dewey Martin'},
   {id: 313, name: 'Bruce Palmer'},
   {id: 456, name: 'Stephen Stills'},
   {id: 177, name: 'Neil Young'}],
  [177, 456, 999]
);
//=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
Try It Yourself

How It Works

That is the docs sample from ramdajs.com. Each record is tested against every id in [177, 456, 999]. Stephen Stills and Neil Young match; 999 has no record; other records have no matching id. Order follows the original records list.

Example 2 — vs R.intersection on Same-Type Primitives

R.intersection finds shared values with R.equals and dedupes. innerJoin needs a predicate for cross-type joins.

Ramda
R.intersection([1, 2, 3, 4], [7, 6, 5, 4, 3]);
//=> [4, 3]

// innerJoin with identity predicate on same-type lists:
R.innerJoin(R.equals, [1, 2, 2, 3], [3, 4]);
//=> [2, 2, 3] — duplicates from xs kept
Try It Yourself

How It Works

R.intersection is the cousin for same-type set overlap — it dedupes and uses R.equals internally. R.innerJoin is more general: you supply the predicate and keep xs order and duplicates. For plain number overlap, prefer intersection; for records vs ids, use innerJoin.

📈 Practical Patterns

R.eqBy field joins, duplicate preservation, then curried partial application with R.__.

Example 3 — R.innerJoin with R.eqBy on a Field

Join user objects against id objects by comparing the projected id field.

Ramda
const users = [
  { id: 1, name: 'Ada' },
  { id: 2, name: 'Grace' },
  { id: 3, name: 'Alan' }
];
const selectedIds = [{ id: 2 }, { id: 3 }];

R.innerJoin(R.eqBy(R.prop('id')), users, selectedIds);
//=> [{ id: 2, name: 'Grace' }, { id: 3, name: 'Alan' }]
Try It Yourself

How It Works

R.eqBy(R.prop('id')) is a binary predicate that compares the id field on both sides. User records and id wrapper objects can match even though their full shapes differ. This is the idiomatic field-join pattern.

Example 4 — Duplicates Preserved from xs

When xs contains duplicate entries that match, every occurrence stays in the result.

Ramda
R.innerJoin(
  (record, id) => record.id === id,
  [{ id: 1, tag: 'a' }, { id: 1, tag: 'b' }, { id: 2, tag: 'c' }],
  [1]
);
//=> [{ id: 1, tag: 'a' }, { id: 1, tag: 'b' }]

R.intersection([1, 1, 2], [1, 3]);
//=> [1] — deduped
Try It Yourself

How It Works

Lists are treated as sets semantically for matching, but xs' does not dedupe. Both records with id: 1 match id 1 in ys, so both appear. Contrast with R.intersection, which returns unique shared values.

Example 5 — Curried Partial Application with R.__

Fix the predicate and ys list once, then pass different xs lists later.

Ramda
const matchById = (record, id) => record.id === id;
const activeIds = [177, 456];
const joinActive = R.innerJoin(matchById, R.__, activeIds);

joinActive([
  { id: 456, name: 'Stephen Stills' },
  { id: 313, name: 'Bruce Palmer' }
]);
//=> [{ id: 456, name: 'Stephen Stills' }]
Try It Yourself

How It Works

R.innerJoin is arity 3 and supports R.__. R.innerJoin(matchById, R.__, activeIds) returns a function waiting for xs. Reuse the same join against many record lists without repeating the predicate and id list.

Browser Support

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

✓ Ramda 0.24.0+ · Any JS runtime

Ramda.js R.innerJoin()

Load Ramda 0.24.0 or later via CDN or npm, then call R.innerJoin with a predicate and two lists. No extra browser API is required.

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

Bottom line: Safe in any project that includes Ramda 0.24.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.innerJoin(pred, xs, ys) returns xs' — each element of xs that matches one or more elements of ys according to the binary predicate pred. Type: ((a, b) → Boolean) → [a] → [b] → [a]. Arity 3, curried. Added in v0.24.0.
R.innerJoin((record, id) => record.id === id, [{id: 824, name: 'Richie Furay'}, {id: 956, name: 'Dewey Martin'}, {id: 313, name: 'Bruce Palmer'}, {id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}], [177, 456, 999]) returns [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] — records whose id appears in the second list, in xs order.
R.intersection compares same-type lists with R.equals and dedupes the result. R.innerJoin takes a custom predicate and can join different shapes (e.g. objects vs ids). innerJoin preserves xs order and does not remove duplicates from xs.
No. xs and ys are treated as sets semantically for matching, but xs' preserves order from xs and keeps duplicates if xs had them. An xs element appears once per occurrence in xs when it matches any ys element.
Yes. Arity 3 and curried, so you can fix pred and ys with R.__ and pass xs later: R.innerJoin(pred, R.__, ys)(xs) or R.innerJoin(pred, R.__, R.__)(ys)(xs).
No. R.innerJoin is a stable Ramda relation helper from v0.24.0. It is not deprecated, experimental, or non-standard.

Continue to R.intersection()

Same-type shared values with R.equals. Deduped result. Order follows list1.

R.intersection() →

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