Is there a JavaScript function that does the opposite of .flat()
?
I have an array like this:
[1, 2, 3, 4, 5]
That needs to become
[[1,2], [3,4], [5]]
Is this possible to do automatically, by specifying the wanted size of the arrays (2: [[1,2], [3,4]]
; 3: [[1,2,3],[4,5]]
)?