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.
size
array
The array to process.
Optional
The length of each chunk
Returns the new array of chunks.
3.0.0
chunk(['a', 'b', 'c', 'd'], 2)// => [['a', 'b'], ['c', 'd']]chunk(['a', 'b', 'c', 'd'], 3)// => [['a', 'b', 'c'], ['d']] Copy
chunk(['a', 'b', 'c', 'd'], 2)// => [['a', 'b'], ['c', 'd']]chunk(['a', 'b', 'c', 'd'], 3)// => [['a', 'b', 'c'], ['d']]
Creates an array of elements split into groups the length of
size
. Ifarray
can't be split evenly, the final chunk will be the remaining elements.