Lodash propertyOf method
语法
The opposite of _.property; this method creates a function that returns the value at a given path of object.
参数
object (Object) − The object to query.
输出
(Function) − Returns the new accessor function.
实例
var _ = require('lodash');
var array = [0, 1, 2];
var object = { 'a': array, 'b': array, 'c': array };
console.log(_.map(['a[2]', 'c[0]'], _.propertyOf(object)));
console.log(_.map([['a', '2'], ['c', '0']], _.propertyOf(object)));
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出