Lodash zipWith method
语法:
_.zipWith([arrays], [iteratee=_.identity])
This method is like _.zip except that it accepts iteratee to specify how grouped values should be combined. The iteratee is invoked with the elements of each group: (...group).
参数
[arrays] (...Array) − The arrays to process.
[iteratee=_.identity] (Function) − The function to combine grouped values.
输出:
(Array) − Returns the new array of grouped elements.
实例:
var _ = require('lodash');
var result = _.zipWith([1, 2], [10, 20], function(a, b) {
return a + b;
});
console.log(result);
Save the above program in
tester.js. Run the following command to execute this program.
命令:
输出: