平等份 分割数组


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
}
var arr = [1,2,3,4,5,6,7,8,9,10,11];
var arrstr = sliceArray(arr, 2)
console.log(arrstr)

你可能感兴趣的:(平等份 分割数组)