Splits an array into groups of a specified size. If the array can't be split evenly, the final chunk will contain the remaining elements.
The array to be chunked.
The size of each chunk (must be a positive integer).
An array of chunks, where each chunk is an array of elements.
chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]] Copy
chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
Splits an array into groups of a specified size. If the array can't be split evenly, the final chunk will contain the remaining elements.