chunk

Array
since 3.0.0

Arguments

  • Array The array to process.
  • number The length of each chunk

Returns

Array the new array of chunks.

Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

Example of Lodash _.chunk

_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]

_.chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]