Ramda.js R.includes() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.includes(value, list) returns true if the list holds an item equal to value, otherwise false. “Equal” means R.equals, so objects and arrays are compared by their contents (official Ramda docs). On a string, it checks for a substring.

Stable since v0.26.0: R.includes is not deprecated, experimental, or non-standard. Renamed: it replaced the deprecated R.contains, which no longer exists in current Ramda.

Syntax

Call R.includes. Start with this line.

Ramda
R.includes(value, list)
CallWhat it does
R.includes(value, list)Primary signature.
R.includes(...)Call the list helper.

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

Library declarations
Ramda
R.includes(value, list)

Parameters

ParameterDescription
valueRequired. Any. The item (or substring) to look for
listOptional. Array or String. Where to look; omit it to get a reusable function

Return Value

Return ValueDescription
*The value returned by R.includes().

Ramda Examples

Example 1 — Official Number Check

Is the number in the list? The first two samples from the Ramda docs.

Ramda
console.log(R.includes(3, [1, 2, 3])); // true
console.log(R.includes(4, [1, 2, 3])); // false
Try It Yourself

How It Works

  1. Value first. The number to find comes before the list.
  2. Found. 3 is at index 2, so the answer is true.
  3. Not found. No item equals 4, so the answer is false.
  4. Always a boolean. You never get an index or the item back — use R.indexOf for that.

Example 2 — Objects and Arrays by Value

The official object samples — and why native includes answers differently.

Ramda
const people = [{ name: 'Fred' }];

console.log(R.includes({ name: 'Fred' }, people)); // true
console.log(R.includes([42], [[42]]));             // true
console.log(people.includes({ name: 'Fred' }));    // false (native)
Try It Yourself

How It Works

  1. A new object. { name: 'Fred' } in the call is a different object from the one in people.
  2. Ramda compares contents. R.equals sees the same keys and values, so it is true.
  3. Arrays too. [42] equals the inner [42] by contents.
  4. Native compares references. Array.prototype.includes only matches the very same object, so it is false.

Example 3 — Strings: Substring vs Whole Item

Searching a string finds substrings; searching an array of strings needs an exact item.

Ramda
console.log(R.includes('ba', 'banana'));   // true
console.log(R.includes('Ba', 'banana'));   // false
console.log(R.includes('ba', ['banana'])); // false
Try It Yourself

How It Works

  1. Substring. 'banana' is a string, so 'ba' is found inside it (the official sample).
  2. Case-sensitive. 'Ba' with a capital B does not appear, so it is false.
  3. Array of strings. ['banana'] has one item, 'banana', which is not equal to 'ba'.
  4. Same as native. This matches String.prototype.includes for strings.

Example 4 — A Reusable “Is Allowed?” Check

Fix the list and leave the value open with R.__, so you get a one-argument checker.

Ramda
const isAllowed = R.includes(R.__, ['admin', 'editor']);

console.log(isAllowed('editor')); // true
console.log(isAllowed('guest'));  // false
Try It Yourself

How It Works

  1. Placeholder. R.__ holds the first slot (the value) open.
  2. List fixed. The allowed roles fill the second slot, so isAllowed waits for one value.
  3. Check. 'editor' is in the list → true; 'guest' is not → false.
  4. Why needed. R.includes('editor') alone would fix the value, not the list.

Example 5 — Keep Only Items from an Allowed List

Use the same curried checker as a predicate inside R.filter.

Ramda
const inStock = ['red', 'green'];
const wanted = ['red', 'blue', 'green', 'pink'];

const available = R.filter(R.includes(R.__, inStock), wanted);

console.log(JSON.stringify(available)); // ["red","green"]
Try It Yourself

How It Works

  1. Predicate. R.includes(R.__, inStock) returns true for colors in stock.
  2. Filter. R.filter keeps 'red' and 'green', and drops 'blue' and 'pink'.
  3. Order kept. Results follow the order of wanted.
  4. Shortcut. For this exact job, R.intersection also works (it removes duplicates too).

Browser & Runtime Support

R.includes() is plain JavaScript inside Ramda 0.26.0+. Unlike native Array.prototype.includes (ES2016), it does not depend on the browser’s array methods, so support depends only on loading Ramda.

✓ Ramda 0.26.0+ · Any JS runtime

Ramda.js R.includes()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import.

100% With Ramda 0.26+ loaded
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.includes() Universal

Bottom line: Safe in any project with Ramda 0.26.0 or later (check with npm ls ramda). On older versions, use R.contains. These labs load [email protected].

Frequently Asked Questions

R.includes(value, list) returns true if at least one item in the list is equal to value in R.equals terms, and false otherwise. When the second argument is a string, it checks for a substring instead.
Native list.includes(value) compares objects by reference, so a different object with the same shape is not found. R.includes compares by value with R.equals, so { name: 'Fred' } matches { name: 'Fred' }. Ramda also takes the value first and the list second, which makes it easy to curry.
Yes. R.includes('ba', 'banana') is true because 'ba' is a substring of 'banana'. The check is case-sensitive. In an array of strings, though, it only matches whole items: R.includes('ba', ['banana']) is false.
R.includes needs the whole object to be equal. For a partial match, use R.any with a predicate, for example R.any(R.propEq(2, 'id'), cart).
R.contains is the old name. It was deprecated when R.includes arrived in v0.26.0 and is not available in current Ramda, so replace R.contains with R.includes when upgrading.
No. R.includes has been a stable Ramda List function since v0.26.0. It is not deprecated, experimental, or non-standard.

Next: R.indexBy()

Turn a list into an object keyed by a field such as an id.

R.indexBy() tutorial →

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