Namespace
The type of elements in the array.
The array to be chunked.
The size of each chunk.
An array of smaller arrays (chunks).
const originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const chunkedArray = chunkArray(originalArray, 3);
console.log(chunkedArray);
// Output: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
const names = ["Alice", "Bob", "Charlie", "David", "Eve"];
const nameChunks = chunkArray(names, 2);
console.log(nameChunks);
// Output: [["Alice", "Bob"], ["Charlie", "David"], ["Eve"]]
Generated using TypeDoc
ArrayUtils
Split an array into smaller arrays of a specified size.