SOURCE

function slice(array, start, end) {
    let length = array === null ? 0 : array.length;
    if (!length) {
        return []
    }
    if (start < 0) {
        start = -start > length ? 0 : length + start;
    }
    end = end === undefined ? length : end;
    if (end < 0) {
        end = -end > length ? 0 : length + end;
    }

    let idx = 0;
    let result = new Array();
    while (start <= end) {
        result[idx++] = array[start++]
    }
    return result;
}
function chunk(array, size = 1){
    size = size < 0 ? -size : size;
    let length = array === null? 0: array.length;
    let idx = 0;
    let resIdx = 0;
    let result = new Array(Math.ceil(length / size));
    while(idx < length){
        result[resIdx ++] = slice(array,idx,idx += size - 1)
    }
    return result;
}
let array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(chunk(array,2))
console 命令行工具 X clear

                    
>
console