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.
命令:
输出: