Lodash教程

Lodash zipObject method

语法:

_.zipObject([props=[]], [values=[]])
This method is like _.fromPairs except that it accepts two arrays, one of property identifiers and one of corresponding values.

参数

[props=[]] (Array) − The property identifiers. [values=[]] (Array) − The property values.

输出:

(Object) − Returns the new object.

实例:

var _ = require('lodash');
 
var result = _.zipObject(['a', 'b'], [1, 2]);
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.

命令:

\>node tester.js

输出:

{ a: 1, b: 2 }
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4