4.17.11
3.10.1
2.4.2
1.3.1
_.method(path, [args])
Creates a function that invokes the method at path
of a given object.
Any additional arguments are provided to the invoked method.
Since
3.7.0
Arguments
argument
path
[args]
type
(Array|string)
...*
description
The path of the method to invoke.
The arguments to invoke the method with.
Returns
(array)
Example
var objects = [
{ a: { b: _.constant(2) } },
{ a: { b: _.constant(1) } },
];
_.map(objects, _.method("a.b"));
// => [2, 1]
_.map(objects, _.method(["a", "b"]));
// => [2, 1]
var objects = [{ a: { b: _.constant(2) } }, { a: { b: _.constant(1) } }];
_.map(objects, _.method("a.b"));
// => [2, 1]
_.map(objects, _.method(["a", "b"]));
// => [2, 1]