Splits an array into smaller chunks of a specified size.
This function takes a source array and divides it into chunks of the given size. Each chunk is represented as an object with a unique key and an array of items.
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9];const chunks = splitIntoChunks(data, 3);// Output: [{ key: 0, items: [1, 2, 3] }, { key: 1, items: [4, 5, 6] }, { key: 2, items: [7, 8, 9] }]
The source array to be split into chunks.
The size of each chunk.
Splits an array into smaller chunks of a specified size.
This function takes a source array and divides it into chunks of the given size. Each chunk is represented as an object with a unique key and an array of items.
Example