Lodash _.zipObject

2021-09-24 09:54 更新

_.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 }


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号