📌  相关文章
📜  如何将数组分成块 - Javascript代码示例

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

代码示例1
function chunkArray(arr,n){
     var chunkLength = Math.max(arr.length/n ,1);
     var chunks = [];
     for (var i = 0; i < n; i++) {
         if(chunkLength*(i+1)<=arr.length)chunks.push(arr.slice(chunkLength*i, chunkLength*(i+1)));
     }
     return chunks; 
 }