Lodash教程

Lodash methodOf method

语法

_.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.

参数

object (Object) − The object to query. [args] (...*) − The arguments to invoke the method with.

输出

(Function) − Returns the new invoker function.

实例

var _ = require('lodash');
var array = _.times(3, _.constant);
var object = { 'a': array, 'b': array, 'c': array };
console.log(_.map(['a[2]', 'c[0]'], _.methodOf(object))); 
console.log(_.map([['a', '2'], ['c', '0']], _.methodOf(object)));
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

[ 2, 0 ]
[ 2, 0 ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4