array to split into chunks
maximum size of each chunk
array of arrays, each containing up to size elements
chunk([1, 2, 3, 4, 5, 6, 7], 3) // [[1, 2, 3], [4, 5, 6], [7]]
chunk(['a', 'b', 'c', 'd'], 2) // [['a', 'b'], ['c', 'd']]
chunk([1, 2], 5) // [[1, 2]]
chunk([], 3) // []
Splits an array into smaller arrays of the specified size.
Divides a large array into multiple smaller arrays (chunks) of the given size. The last chunk may be smaller if the array length is not evenly divisible.