Skip to main content

method

_.method(path) # Ⓢ [Ⓣ][1] Ⓝ

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​

  1. path (Array|string): The path of the method to invoke.

Returns​

(Function): Returns the new invoker function.

Example​

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

_.map(_.method('a.b'), objects);
// => [2, 1]

_.map(_.method(['a', 'b']), objects);
// => [2, 1]