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 + 1) * size)
        res.push(temp);
    }
    return res;
}
posted @ 2020-09-29 12:15  671_MrSix  阅读(83)  评论(0编辑  收藏  举报