Lodash _.includes() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.includes(collection, value, [fromIndex]) answers presence questions across collection types.
  • SameValueZero perks on arrays (NaN) versus strict equality pitfalls elsewhere.
  • When indexOf, some, or native Array.prototype.includes might win.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Skim _.filter() or _.find() when you need every match—not just a yes/no.

  • You know arrays store ordered elements and plain objects map keys to values.
  • You can open Try-it labs or run snippets locally.

Overview

_.includes is the universal presence probe—arrays, strings-as-text, or object value bags—without writing bespoke loops each time.

Boolean clarity

Returns true/false instead of sentinel indexes.

NaN friendly

Array scans honor SameValueZero so NaN finds itself.

Objects too

Plain-object collections scan enumerable values.

Syntax

javascript
_.includes(collection, value, [fromIndex])
  • collection: array-like list, string, or plain object Lodash can inspect.
  • value: needle to locate—interpretation depends on collection type.
  • fromIndex (optional): starting position for array-like searches.
  • Returns: boolean.
1

Array membership

The everyday case—does this primitive appear anywhere in the list?

javascript
import includes from "lodash/includes";

[ includes([1, 2, 3], 2), includes([1, 2, 3], 9) ];
// → [true, false]
Try it Yourself
2

Search plain-object values

Keys are ignored—Lodash walks values and compares against your needle.

javascript
import includes from "lodash/includes";

includes({ sku: "A1", name: "bolt" }, "bolt");
// → true
Try it Yourself
3

Array scan with fromIndex

Skip early duplicates—start searching after the first occurrence.

javascript
import includes from "lodash/includes";

includes([10, 20, 30, 10], 10, 1);
// → true (matches the trailing 10)
Try it Yourself

📋 _.includes vs indexOf, some, native includes

APIReturnsBest when
_.includes(collection, value)booleanUniform checks across objects, arrays, strings
_.indexOf(array, value)index or -1You need the position, not just truthiness
_.some(collection, predicate)booleanMatching logic is a predicate function
Array.prototype.includesbooleanPure arrays and tree-shaking without Lodash

Pitfalls to avoid

Objects

Keys versus values

Remember Lodash inspects values—probe keys with has, keyBy, or explicit lookups.

Strings

Substring semantics

String collections search substrings; do not expect per-character array behavior unless you pass an array of characters.

Perf

Huge collections

Linear scans add up—sorted data might deserve binary helpers from the array toolkit instead.

❓ FAQ

No—it only inspects your array, string, or object.
On plain objects it searches enumerable values. Use _.has or key checks when you care about property names.
Lodash applies SameValueZero rules for array-like membership, aligning with Array.prototype.includes semantics.
For arrays it mirrors familiar index-from semantics—negative indexes count back from the end when supported by the underlying helpers.
When the collection is a string, Lodash treats the second argument as a substring probe—not an array of characters unless you pass one.

Summary

Did you know?

For arrays, _.includes uses SameValueZero equality—so NaN can match NaN like modern Array.prototype.includes. For plain objects, Lodash checks values, not keys.

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