Skip to content

pick

js
_.pick(object, [paths])

创建一个由选定的 object 属性组成的对象。

¥Creates an object composed of the picked object properties.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. object (对象):源对象。

    ¥object (Object): The source object.

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

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

返回

¥Returns

(对象):返回新对象。

¥(Object): Returns the new object.

示例

¥Example

js
var object = { 'a': 1, 'b': '2', 'c': 3 };

_.pick(object, ['a', 'c']);
// => { 'a': 1, 'c': 3 }

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