主题
invoke
js
_.invoke(object, path, [args])调用 object 中 path 处的方法。
¥Invokes the method at path of object.
新增于
¥Since
4.0.0
参数
¥Arguments
object(对象):的反面;¥
object(Object): The object to query.path(数组|字符串):要调用的方法的路径。¥
path(Array|string): The path of the method to invoke.[args](...*):用于调用方法的参数。¥
[args](...)*: The arguments to invoke the method with.
返回
¥Returns
(*):返回调用方法的结果。
¥()*: Returns the result of the invoked method.
示例
¥Example
js
var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
_.invoke(object, 'a[0].b.c.slice', 1, 3);
// => [2, 3]