Skip to content

zipObject

js
_.zipObject([props=[]], [values=[]])

此方法与 _.fromPairs 类似,不同之处在于它接受两个数组,一个是属性标识符,另一个是相应值。

¥This method is like _.fromPairs except that it accepts two arrays, one of property identifiers and one of corresponding values.

新增于

¥Since

0.4.0

参数

¥Arguments

  1. [props=[]] (数组):属性值。

    ¥[props=[]] (Array): The property identifiers.

  2. [values=[]] (数组):语义版本号。

    ¥[values=[]] (Array): The property values.

返回

¥Returns

(对象):返回新对象。

¥(Object): Returns the new object.

示例

¥Example

js
_.zipObject(['a', 'b'], [1, 2]);
// => { 'a': 1, 'b': 2 }

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