js将一位数组分割成每三个一组
js数组按指定数量进行分割
var data = [
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
{name:'Liming',age:'25'},
]
var result = [];
for(var i=0;i<data.length;i+=3){
result.push(data.slice(i,i+3));
}
版权声明
本站部分原创文章,部分文章整理自网络。如有转载的文章侵犯了您的版权,请联系站长删除处理。如果您有优质文章,欢迎发稿给我们!联系站长:
愿本站的内容能为您的学习、工作带来绵薄之力。
评论