Skip to main content

chunk

_.chunk(size, array) # Ⓢ [Ⓣ][1] Ⓝ

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.

Since​

3.0.0

Arguments​

  1. size (number): The length of each chunk
  2. array (Array): The array to process.

Returns​

(Array): Returns the new array of chunks.

Example​

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

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