I have code like this:
for (const item of items) {
myMap[`${item.id}`] = {
valueA: item.A,
valueB: item.B,
valueC: item.C,
valueD: item.D
};
}
This is creating output like:
"1234": {
"valueA": "A",
"valueB": "B",
"valueC": "C",
"valueD": "D"
},
"5678": {
"valueA": "E",
"valueB": "F",
"valueC": "G",
"valueD": "H"
},
"9876": {
"valueA": "A",
"valueB": "B",
"valueC": "C",
"valueD": "D"
}
The id is changing but the contents of the object within the map are the same. How can I amend this so a value only gets added to the map collection if the entire contents of the map are unique. So in my example data above the item with id 9876 would not get added too myMap because the values are already present with id 1234