function updateArr() {
    var random = [11,22,33,44,55];
    var newArr = [];
    var json = {};
    var j = 0;
    for(var i in random){
        newArr.push(random[i]);
        i ++;
        if(i %2 === 0){
            j ++;
            json['list' + j] = newArr;
            newArr = [];
        }else if(i === random.length){
            j ++;
            json['list' + j] = newArr;
        }
    }
    console.log(json); // {list1:[11, 22], list2:[33, 44], list3:[55]}
}


本文转载:CSDN博客