Recently delving into the world of JavaScript and trying to grasp the concept of maps.
This is the code snippet I'm currently working with:
const topmap = new Map();
const map1 = new Map();
const map2 = new Map();
const set1 = new Set();
map1.set('x','y');
map1.set('a','b');
set1.add(map1);
set1.add(map2);
topmap.set('ID',set1);
console.log(topmap.get('ID').size);
topmap.get('ID').forEach(x => {
if(x.has('x')){x.delete('x')} )
}
)
console.log(topmap.get('ID').size)
Can someone help explain why both lines are returning a size of 2 even after deleting one map in line 18?