Lodash教程

Lodash propertyOf method

语法

_.propertyOf(object)
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

\>node tester.js

输出

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