js一个数组变为指定长度的多个数组
var dataArr = [0,1,2,3,4,5,6,7,8,9,10];
var newArr = [];
var s = parseInt(dataArr.length / 4);
var n = 0;
for (var i = 1; i <= s; i++) {
var star = (i - 1) * 4;
newArr[n++] = dataArr.slice(star, star + 4);
}
var y = dataArr.length - s * 4;
if (y > 0) {
newArr[n++] = dataArr.slice(s * 4);
}
console.log(newArr);