比如arr1 = [1,2,3,4,5,6,7,8,9,10];按每三个一组拆分想得到arr2 = [[1,2,3],[4,5,6],[7,8,9],[10]];
1 回答
一只斗牛犬
TA贡献1784条经验 获得超2个赞
var arr =[1,2,3,4,5,6,7,8,9,10];
var result = _.toArray(_.groupBy(arr, function(num, index){ return Math.floor(index/3);}));
添加回答
举报
0/150
提交
取消