Lodash _.invokeMap() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Collection

Definition

Invokes the method at path on each element of a collection and returns an array of results. Extra arguments are forwarded to every call. If path is a function, it runs with each element as this. Part of Lodash 4.x Collection (since 4.0.0).

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

Syntax

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

Lodash
_.invokeMap(collection, path, [args])
CallWhat it does
_.invokeMap(collection, path, [args])Primary signature.
_.invokeMap(collection)Call with a collection argument.

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

Library declarations
Lodash
_.invokeMap(collection, path, [args])

Parameters

ParameterDescription
collectionRequired. Array or object to iterate
pathRequired. Method path or function to invoke
argsOptional. Arguments forwarded to every call

Return Value

Return ValueDescription
*New array of invocation results

Lodash Examples

Example 1 — Official: Sort Nested Arrays

Call sort on every nested array.

Lodash
_.invokeMap([[5, 1, 7], [3, 2, 1]], "sort");
// → [[1, 5, 7], [1, 2, 3]]
Try It Yourself

How It Works

  1. Path. "sort" resolves to each array’s sort method.
  2. Call. Lodash runs sort with that array as this.
  3. Collect. Each sorted array is pushed into a new results list.
  4. Mutate. The nested arrays themselves are reordered in place.

Example 2 — Official: Function Path (String.prototype.split)

Pass a function so each number is treated as this for split.

Lodash
_.invokeMap([123, 456], String.prototype.split, "");
// → [["1", "2", "3"], ["4", "5", "6"]]
Try It Yourself

How It Works

  1. Function path. Lodash does not look up a property — it calls the function.
  2. this. Each number becomes this (coerced when split runs).
  3. Arg. "" is the separator for every call.
  4. Result. Digit arrays land in the output.

Example 3 — Method Path With Arguments

Split each string with the same delimiter.

Lodash
_.invokeMap(["a-b-c", "d-e"], "split", "-");
// → [["a", "b", "c"], ["d", "e"]]
Try It Yourself

How It Works

  1. Lookup. Each string’s split method is resolved.
  2. Shared arg. "-" is passed to both calls.
  3. Collect. Token arrays form the result.
  4. vs map. Same idea as _.map(arr, s => s.split("-")), less boilerplate.

Example 4 — Slice From Index 1

Forward a start index to each nested array’s slice.

Lodash
_.invokeMap([[1, 2, 3], [4, 5]], "slice", 1);
// → [[2, 3], [5]]
Try It Yourself

How It Works

  1. Method. slice is non-mutating — originals stay intact.
  2. Arg. Start index 1 drops the first element of each array.
  3. Results. New sliced arrays fill the output.
  4. Tip. Prefer slice over splice when you need copies.

Example 5 — Custom Object Method

Invoke a named method that uses this on each object.

Lodash
_.invokeMap(
  [
    { n: 2, double: function () { return this.n * 2; } },
    { n: 3, double: function () { return this.n * 2; } }
  ],
  "double"
);
// → [4, 6]
Try It Yourself

How It Works

  1. Resolve. Lodash finds double on each object.
  2. this. Calling through the object keeps this.n correct.
  3. Return. 4 then 6 fill the results array.
  4. Why. Avoids ripping methods off objects and losing this.

Browser & Runtime Support

_.invokeMap is a Lodash 4.x Collection helper (since 4.0.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. There is no single native equivalent for path-based batch invoke.

✓ Stable · Lodash 4.0+

_.invokeMap()

Available in [email protected] full builds and the lodash/invokeMap 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
_.invokeMap Lodash 4.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import invokeMap from "lodash/invokeMap" for smaller builds. Use native map when you already write a one-off iteratee.

Frequently Asked Questions

_.invokeMap(collection, path, ...args) calls the method at path on each element (or calls path as a function with this bound to the element) and returns an array of results.
It always returns a new results array. Mutating methods like Array.prototype.sort still change the elements they run on.
map runs any iteratee you write. invokeMap is for “call this method path (or function) on each item with the same args.”
Yes. Lodash invokes it with each element as this and passes your trailing args.
That slot is usually undefined. Guard risky paths when elements may lack the method.
_.invoke targets one object. _.invokeMap does the same idea across a whole collection.

Next: _.keyBy()

Index collection elements by a generated key.

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