jq 给数组对象添加一条新的数据

var data_list = {
    "list":[
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"},
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"},
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"},
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"},
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"},
        {"guatitle": "已婚", "guadate": "2019-12-2611:02:14"}
    ]
}

var arr_Data = [
    {"guatitle": "未婚1", "guadate": "2019-12-2611:02:14"}
]
for (var i = 0; i < arr_Data.length; i++) {
    data_list.list.push({"guatitle":arr_Data[i].guatitle,"guadate":arr_Data[i].guadate})
}



//结果
{ list:
   [ { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '已婚', guadate: '2019-12-2611:02:14' },
     { guatitle: '未婚1', guadate: '2019-12-2611:02:14' } ] }

你可能感兴趣的:(Jquery)