Split an array into smaller chunks. Each chunk will have a maximum length defined by the length parameter.
length
The type of elements in the array.
The target array.
The maximun length of each chunk.
An array of chunks.
const mynumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]console.log(PUtilsArray.chunks(mynumbers, 3))// [// [0, 1, 2],// [3, 4, 5],// [6, 7, 8],// [9],// ] Copy
const mynumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]console.log(PUtilsArray.chunks(mynumbers, 3))// [// [0, 1, 2],// [3, 4, 5],// [6, 7, 8],// [9],// ]
Split an array into smaller chunks. Each chunk will have a maximum length defined by the
length
parameter.