Lodash _.method() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a function that invokes the method at path on a given object. Extra arguments are forwarded to that method. Part of Lodash Util since 3.7.0 (stable — not deprecated).

Note: The path is fixed; the object is supplied later — ideal for _.map when every item exposes the same method.

Syntax

Call _.method. Start with this line.

Lodash
_.method(path, [args])
CallWhat it does
_.method(path, [args])Primary signature.
_.method(...)Call the util helper.

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

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

Parameters

ParameterDescription
pathRequired. String or array path of the method to invoke
argsOptional. Arguments forwarded to the method

Return Value

Return ValueDescription
*Invoker (object) → result

Lodash Examples

Example 1 — Official: Map with Dot Path

Invoke the same nested method on every object in a list.

Lodash
var objects = [
  { 'a': { 'b': _.constant(2) } },
  { 'a': { 'b': _.constant(1) } }
];

_.map(objects, _.method('a.b'));
// → [2, 1]
Try It Yourself

How It Works

  1. Setup. Each object has a nested function at a.b (via _.constant).
  2. Invoker. _.method('a.b') means “call object.a.b().”
  3. Map. Runs that invoker on every item.
  4. Result. [2, 1] — return values of each call.

Example 2 — Official: Path Array

Same behavior with an array path instead of a dotted string.

Lodash
var objects = [
  { 'a': { 'b': _.constant(2) } },
  { 'a': { 'b': _.constant(1) } }
];

_.map(objects, _.method(['a', 'b']));
// → [2, 1]
Try It Yourself

How It Works

  1. Array path. ['a', 'b'] resolves like 'a.b'.
  2. Same invoker. Still calls the nested function on each object.
  3. Result. Identical output: [2, 1].
  4. Pick a style. Use arrays when keys contain dots or for clarity.

Example 3 — Bound Method Arguments

Arguments after path are passed into the method on every call.

Lodash
var people = [
  { greet: function (name) { return 'Hi, ' + name; } },
  { greet: function (name) { return 'Hello, ' + name; } }
];

_.map(people, _.method('greet', 'Ada'));
// → ['Hi, Ada', 'Hello, Ada']
Try It Yourself

How It Works

  1. Bind early. 'Ada' is captured when creating the invoker.
  2. Per object. Each greet runs as greet('Ada').
  3. Map. Collects the returned strings.
  4. Rule. Object is the only argument to the invoker — method args are pre-bound.

Example 4 — Call the Invoker Directly

You do not need _.map — call the returned function on one object.

Lodash
var obj = { a: { b: _.constant(2) } };

var invoke = _.method('a.b');
invoke(obj);
// → 2

_.invoke(obj, 'a.b');
// → 2  // one-shot form
Try It Yourself

How It Works

  1. Factory. Build an invoker once with _.method.
  2. Call. Pass a single object → method runs.
  3. Compare. _.invoke does the same for one immediate call.
  4. Choose. Reuse → method; one-off → invoke.

Example 5 — method vs property

One calls a function at the path; the other only reads the value.

Lodash
var objects = [
  { a: { b: _.constant(2) } },
  { a: { b: _.constant(1) } }
];

_.map(objects, _.method('a.b'));
// → [2, 1]          // calls the functions

_.map(objects, _.property('a.b'));
// → [ƒ, ƒ]          // returns the functions themselves
Try It Yourself

How It Works

  1. method. Resolves the path and invokes it → numbers.
  2. property. Resolves the path and returns it → functions.
  3. Rule. Need a call? Use method. Need a getter? Use property.
  4. Output note. The demo prints "function" for clarity in text.

Browser & Runtime Support

_.method is a Lodash Util helper since 3.7.0. It runs anywhere Lodash 3.7+ / 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.7.0+

_.method()

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

100% With Lodash 3.7+
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
_.method Lodash 3.7.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import method from "lodash/method" for smaller bundles. Pair with _.map when every item shares the same method path.

Frequently Asked Questions

_.method(path, …args) returns a function. Give that function an object and it invokes the method at path on that object, passing any args you bound when creating the invoker.
Extra arguments after path are bound when you call _.method—not when you call the returned function. Example: _.method('greet', 'Hi')(obj) calls obj.greet('Hi').
_.invoke(object, path, …args) runs once immediately. _.method(path, …args) returns a reusable invoker for many objects or for _.map.
_.method(path) fixes the path—the object comes later. _.methodOf(object) fixes the object—the path comes later.
Yes. That is the official pattern: _.map(objects, _.method('a.b')) calls the method at a.b on each item and collects the results.
If the path cannot be invoked, Lodash returns undefined (it does not throw). Guard critical paths or ensure every object exposes the method.

Next: _.methodOf()

Create an invoker bound to one object — supply the method path later.

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

10 people found this page helpful