The opposite of _.method: creates a function that invokes the method at a given path on a fixed object. Extra arguments are forwarded to that method. Part of Lodash Util since 3.7.0 (stable — not deprecated).
Note: The object is fixed; the path is supplied later — ideal for _.map over a list of paths against one target.
Syntax
Call _.methodOf. Start with this line.
Lodash
_.methodOf(object, [args])
Call
What it does
_.methodOf(object, [args])
Primary signature.
_.methodOf(...)
Call the util helper.
Prefer import methodOf from "lodash/methodOf" when you want a smaller bundle.
Same invoker. Still calls the function at that path on object.
Result. Identical output: [2, 0].
Pick a style. Arrays help when keys are dynamic or numeric.
Example 3 — Bound Method Arguments
Arguments after object are passed into every invoked method.
Lodash
var calc = {
add: function (a, b) { return a + b; },
mul: function (a, b) { return a * b; }
};
var run = _.methodOf(calc, 10, 5);
run('add');
// → 15
run('mul');
// → 50
Rule. Many paths / one object → methodOf; many objects / one path → method.
Compatibility
Browser & Runtime Support
_.methodOf 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+
_.methodOf()
Available in [email protected] full builds and the lodash/methodOf modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 3.7+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.methodOfLodash 3.7.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import methodOf from "lodash/methodOf" for smaller bundles. Pair with _.map when you have many paths on one object.
Frequently Asked Questions
_.methodOf(object, …args) returns a function that takes a path and invokes the method at that path on the fixed object, forwarding any args you bound when creating the invoker. It is the opposite of _.method.
A path (string or array)—not the object. Example: _.methodOf(object)('a[2]') calls the method at object.a[2].
Arguments after object in _.methodOf are bound at create time. Example: _.methodOf(calc, 10, 5)('add') calls calc.add(10, 5).
_.method(path) fixes the path—the object comes later. _.methodOf(object) fixes the object—the path comes later. Mirror-image invoker factories.
No. That treats 'greet' as a method argument, not a path. Use _.methodOf(object)('greet') or _.method('greet')(object).
Use it when one object exposes several methods and you pick the path at runtime—dispatch tables, registries, or mapping a list of paths against a fixed target.