📌  相关文章
📜  如何在js中将数组分成两部分 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:45.698000             🧑  作者: 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; 
 }