Operation of the array of objects

Merge array 
this.multipleSelection.forEach ((Val) => {
this.returnData.push (Val)
})


based on the unique identification of the array of objects to heavy
let hash = {};
this.returnData = this.returnData.reduce((preVal, curVal) => {
hash[curVal.skuId] ? '' : hash[curVal.skuId] = true && preVal.push(curVal);
return preVal
}, [])


Guess you like

Origin www.cnblogs.com/src-w/p/11237991.html