📌  相关文章
📜  将数组拆分为块 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:23.455000             🧑  作者: Mango

代码示例6
let input = [1,2,3,4,5,6,7,8];
let chunked = []
let size = 2;

Array.from({length: Math.ceil(input.length / size)}, (val, i) => {
  chunked.push(input.slice(i * size, i * size + size))
})

console.log(chunked);