var obj1 = [{
"id": 1,
"model": "XQG70-S1208FW",
"color": "白",
"invStatusName": "正品",
"bactualQty": 10947,
"brealyQty": 11000,
"bavailQty": 53
}, {
"id": 2,
"model": "XQB70-C3006",
"color": "灰",
"invStatusName": "正品",
"bactualQty": 11,
"brealyQty": 6,
"bavailQty": -5
}];
var obj2 = [{
"price": "6666",
"id": 2
}, {
"id": 1,
"price": "8888"
}];
var bb = [];
obj1.forEach(function(item,index) {
bb.push(tt(item))
});
function tt(item) {
let data;
obj2.forEach(function (items, index) {
if(item.id == items.id){
data = Object.assign({}, item,items)
}
})
return data
}
console.log(bb);
网友评论