Lodash教程

Lodash zip method

语法:

_.zip([arrays])
Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on.

参数

[arrays] (...Array) − The arrays to process.

输出:

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

实例:

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

命令:

\>node tester.js

输出:

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