js 一个数组改成两个一组两个一组

var arr= [];

var data=[{name:'abc1'},{name:'abc2'},{name:'abc3'},{name:'abc4'},{name:'abc5'},{name:'abc6'},{name:'abc7'}]


for(var i=0;i<data.length;i+=2){
arr.push(data.slice(i,i+2));
}

 

posted @ 2020-09-15 17:30  瑶玲  阅读(3053)  评论(0编辑  收藏  举报