阅读(3998) (12)

Lodash _.zipObject

2021-09-18 10:47:51 更新

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

这个方法类似_.fromPairs,除了它接受2个数组,第一个数组中的值作为属性标识符(属性名),第二个数组中的值作为相应的属性值。

添加版本

0.4.0

参数

  1. [props=[]] (Array): The property identifiers.
  2. [values=[]] (Array): The property values.

返回

(Object): Returns the new object.

例子

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