[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]
[[1,2,3,4],[5,6,7,8],[9.10,11,12].[13,14,15,16],[17,18,19,20]...]
const getChunks = (arr, chunkSize) =>
Array.from(
{ length: Math.ceil(arr.length / chunkSize) },
(n, i) => arr.slice(i * chunkSize, (i + 1) * chunkSize)
);
// или
const getChunks = (arr, chunkSize) =>
arr.reduce((acc, n, i) => (
i = i / chunkSize | 0,
(acc[i] = acc[i] || []).push(n),
acc
), []);
// или
const getChunks = (arr, chunkSize) =>
arr.reduce((acc, n, i) => (
(i % chunkSize) || acc.push([]),
acc[acc.length - 1].push(n),
acc
), []);
const arr = [...Array(50).keys()];
const chunks = getChunks(arr, 7);
var a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49];
var n = 4;
var result;
result = Array(Math.ceil(a.length / 4)).fill(0).map( (v, i) => a.slice(i*n, (i+1)*n) );
result = Array(Math.ceil(a.length / 4)).fill(0).map( (v, i, array) => ( l = a.slice(i*n, (i+1)*n) ).concat( Array( Math.max(0, n - l.length) ).fill(0) ) );