Skip to content

at

js
_.at(object, [paths])

创建与 objectpaths 相对应的值数组。

¥Creates an array of values corresponding to paths of object.

新增于

¥Since

1.0.0

参数

¥Arguments

  1. object (对象):要迭代的对象。

    ¥object (Object): The object to iterate over.

  2. [paths] (...(字符串|字符串[])):要选择的属性路径。

    ¥[paths] (...(string|string[])): The property paths to pick.

返回

¥Returns

(数组):返回选定的值。

¥(Array): Returns the picked values.

示例

¥Example

js
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };

_.at(object, ['a[0].b.c', 'a[1]']);
// => [3, 4]

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