将一个数组分割成多个
function sliceArray(array, size) { var result = []; for (var x = 0; x < Math.ceil(array.length / size); x++) { var start = x * size; var end = start + size; result.push(array.slice(start, end)); } return result; }
let list = [1,2,3,4,5,6,7,8]
console.log(sliceArray(list,3)); //[[1,2,3],[4,5,6],[7,8]]