Skip to content

propertyOf

js
_.propertyOf(object)

选项对象。此方法创建一个函数,该函数返回 object 的给定路径处的值。

¥The opposite of _.property; this method creates a function that returns the value at a given path of object.

新增于

¥Since

3.0.0

参数

¥Arguments

  1. object (对象):的反面;

    ¥object (Object): The object to query.

返回

¥Returns

(函数):返回新的访问器函数。

¥(Function): Returns the new accessor function.

示例

¥Example

js
var array = [0, 1, 2],
    object = { 'a': array, 'b': array, 'c': array };

_.map(['a[2]', 'c[0]'], _.propertyOf(object));
// => [2, 0]

_.map([['a', '2'], ['c', '0']], _.propertyOf(object));
// => [2, 0]

Lodash v4.17 中文网 - 粤ICP备13048890号