_.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
path
(Array|string): The path of the method to invoke.[args]
(…*): The arguments to invoke the method with.
Returns
(Function): Returns the new invoker function.
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]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .