-
Notifications
You must be signed in to change notification settings - Fork 5
chunk
Subhajit Sahu edited this page Mar 17, 2020
·
22 revisions
Splits array into chunks of given size.
array.chunk(x, [n]);
// x: an array
// n: chunk size (1)
// --> chunks
const array = require('extra-array');
var x = [1, 2, 3, 4, 5];
array.chunk(x, 2);
// [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ]
array.chunk(x, 3);
// [ [ 1, 2, 3 ], [ 4, 5 ] ]