just wondering what the best way to do this is. I set up a javascript map. then I assign instances of the map to an object. however when I change one of the instances of the object it changes other instances of the map. so if your run the code below you will notice temparature is changed to 10 for all instances of cold where it should do if just for the last one.
I put the a runnable snippet below. and I also have a fiddle here https://jsfiddle.net/bupLsf9n/ (I think it is easier to read the console.log on the fiddle)
var myMap = new Map([
["hot", { temperature: 100 }],
["warm", { temperature: 50 }],
["cold", { temperature: 0 }],
]);
var data = [
{ id: 1, map: myMap.get("hot") },
{ id: 2, map: myMap.get("warm") },
{ id: 3, map: myMap.get("cold") },
{ id: 4, map: myMap.get("hot") },
];
$(document).ready(function() {
data.filter(x => x.id == 4)[0].map.temperature = 10;
console.log(data);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>