Im having 2 array object
1.
itemMapping = {
id:1,
hierarchyDesc:"Men's casual",
style:"Denim Pants",
styleDesc:"VS pants",
color:"blue"
}
mapData = {
hierarchyDesc:"Women's casual",
style:"Cotton Pants",
styleDesc:"pants"
}
I need to compare each itemMapping's key with each mapData's key and form an newArray,
if any of keys are matching, (for ex: here in itemMapping and mapData - hierarchyDesc, style, styleDesc are there in both) then take those matching objects entries from mapData array and push to newArray,
if its not matching and is only in itemMapping array then take those not matching object entries from itemMapping array and push to newArray.
Note: all the object key of mapData will be present in itemMapping but vice versa is not true.
expected result:
newArray = {
id:1,
hierarchyDesc:"Women's casual",
style:"Cotton Pants",
styleDesc:"pants",
color:"blue"
}
how can I achieve it in Javascript?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…