合并数组或者对象在数组或对象前面加...,是es6的新写法,然后数组的map方法会返回数组.
var obj1 = [{ "id": 980550455852, "model": "XQG70-S1208FW", "color": "白", "invStatusName": "正品", "bactualQty": 10947, "brealyQty": 11000, "bavailQty": 53 }, { "id": 980550566221, "model": "XQB70-C3006", "color": "灰", "invStatusName": "正品", "bactualQty": 11, "brealyQty": 6, "bavailQty": -5 }]; var obj2 = [{ "price": "6666" }, { "price": "8888" }]; var obj = obj1.map((item,index) => { return {...item, ...obj2[index]}; }); console.log(obj);
原文地址:https://www.cnblogs.com/xiaoxiao2017/p/11644819.html
时间: 2024-11-06 16:11:29