Lodash _.includes() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Collection

Definition

Checks whether value is in a collection. Arrays and objects use SameValueZero equality; strings are checked for a substring. Optional fromIndex starts the search later (negative counts from the end). Part of Lodash 4.x Collection.

Pass the required arguments shown below. Lodash Collection helpers usually return a new value — check whether the source is mutated.

Syntax

Call _.includes on a collection. Start with this line.

Lodash
_.includes(collection, value, [fromIndex=0])
CallWhat it does
_.includes(collection, value, [fromIndex=0])Primary signature.
_.includes(collection)Call with a collection argument.

Prefer import includes from "lodash/includes" when you want a smaller bundle.

Library declarations
Lodash
_.includes(collection, value, [fromIndex=0])

Parameters

ParameterDescription
collectionRequired. Array, object, or string to inspect
valueRequired. Element / value / substring to find
fromIndexOptional. Start index; default 0; negative from end

Return Value

Return ValueDescription
*true or false

Lodash Examples

Example 1 — Official: Array Membership

Check whether a number exists in an array.

Lodash
_.includes([1, 2, 3], 1);
// → true

_.includes([1, 2, 3], 9);
// → false
Try It Yourself

How It Works

  1. Scan. Lodash walks the array with SameValueZero.
  2. Hit. Index 0 equals 1 → true.
  3. Miss. 9 never appears → false.
  4. No mutate. The array is unchanged.

Example 2 — Official: Start Later With fromIndex

Skip earlier elements so a match can be missed on purpose.

Lodash
_.includes([1, 2, 3], 1, 2);
// → false

_.includes([10, 20, 30, 10], 10, 1);
// → true
Try It Yourself

How It Works

  1. First call. Start at index 2 — only 3 remains; 1 is skipped.
  2. Second call. Start at index 1; later 10 at index 3 matches.
  3. Negative. A negative fromIndex counts from the end.
  4. Use. Search for “another” occurrence after a known position.

Example 3 — Official: Object Values

Plain objects are checked by enumerable values.

Lodash
_.includes({ a: 1, b: 2 }, 1);
// → true

_.includes({ a: 1, b: 2 }, "a");
// → false   // keys are not searched
Try It Yourself

How It Works

  1. Values. Lodash sees 1 and 2.
  2. Match. 1 equals a value → true.
  3. Key miss. "a" is a key name, not a value → false.
  4. Keys? Use _.has(obj, key) when you need property names.

Example 4 — Official: Substring Check

When the collection is a string, the needle is a substring.

Lodash
_.includes("abcd", "bc");
// → true

_.includes("abcd", "xyz");
// → false
Try It Yourself

How It Works

  1. String mode. Lodash looks for consecutive characters.
  2. Hit. "bc" appears inside "abcd".
  3. Miss. "xyz" does not.
  4. Not chars. This is not “array of characters” unless you pass one.

Example 5 — NaN With SameValueZero

NaN can be found — unlike classic indexOf.

Lodash
_.includes([1, NaN, 3], NaN);
// → true

_.indexOf([1, NaN, 3], NaN);
// → -1
Try It Yourself

How It Works

  1. SameValueZero. Treats NaN as equal to NaN.
  2. includes. Finds the middle slot → true.
  3. indexOf. Uses strict equality; NaN === NaN is false → -1.
  4. Tip. Prefer includes when NaN may appear.

Browser & Runtime Support

_.includes is a Lodash 4.x Collection helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.includes / String.prototype.includes are ES2016 and array/string only.

✓ Stable · Lodash 4.x

_.includes()

Available in [email protected] full builds and the lodash/includes modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
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
_.includes Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import includes from "lodash/includes" for smaller builds. Use Lodash when you need one API for arrays, objects, and strings.

Frequently Asked Questions

_.includes(collection, value, fromIndex) returns true if value is found. Arrays and objects use SameValueZero equality. Strings are checked for a substring.
No. It only reads the collection and returns a boolean.
For array-like collections it is where the search starts (default 0). A negative fromIndex counts from the end.
No. On plain objects it searches enumerable values, not key names.
Yes. SameValueZero treats NaN as equal to NaN — like Array.prototype.includes.
includes returns a boolean and supports NaN. indexOf returns a numeric index (or -1) and uses strict equality for NaN (never finds it).

Next: _.invokeMap()

Call a method on every element and collect the results.

_.invokeMap() 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.

9 people found this page helpful