Lodash教程

Lodash unzipWith method

语法:

_.unzipWith(array, [iteratee=_.identity])
This method is like _.unzip except that it accepts iteratee to specify how regrouped values should be combined. The iteratee is invoked with the elements of each group: (...group).

参数

array (Array) − The array of grouped elements to process. [iteratee=_.identity] (Function) − The function to combine regrouped values.

输出:

(Array) − Returns the new array of regrouped elements.

实例:

var _ = require('lodash');
var result = _.zip([1, 2], [10, 20]);
console.log(result);
result = _.unzipWith(result, _.add);
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.

命令:

\>node tester.js

输出:

[ [ 1, 10 ], [ 2, 20 ] ]
[ 3, 30 ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4