_.methodOf(object, [args])
The opposite of _.method
; this method creates a function that invokes the method at a given path of object
. Any additional arguments are provided to the invoked method.
Since
3.7.0
Arguments
object
(Object): The object to query.[args]
(…*): The arguments to invoke the method with.
Returns
(Function): Returns the new invoker function.
Example
var array = _.times(3, _.constant),object = { 'a': array, 'b': array, 'c': array };_.map(['a[2]', 'c[0]'], _.methodOf(object));// => [2, 0]_.map([['a', '2'], ['c', '0']], _.methodOf(object));// => [2, 0]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .