myChunk


Array.prototype.myChunk = function(size){
    let { length } = this,line = Math.ceil(length / size),res = [];
    for(let i = 0;i < line;i++){
        let temp = arr.slice(i * size,i * size + size)
        res.push(temp);
    }
    return res;
}

相关