function group(arr, step) { return arr.reduce((x, y) => { return Array.isArray(x) ? (x[x.length - 1].push(y) == step ? [...x, []] : x) : [[x, y]]; }) } group([1, 2, 3, 4, 5, 6, 7, 8, 9, 0],3)
js 数组分组
原文:https://www.cnblogs.com/zhuwansu/p/13036358.html