I have tested this code
const map1 = new Map();
let foo = function() {
this.test = 1;
}
let foo2 = new foo();
map1.set('bar', foo2);
foo2.test = 2;
console.log(map1.get('bar').test);
// prints 2, not 1
on the code snippet section of
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set
However this behavior is not specified anywhere in the same document and I couldn't find any other reference by googling.
Notice that in the Map.get document, it is stated clearly that
If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map object.
My question is, is the above Map.set behavior guaranteed to work in all implementations and all versions of javascript, or is the behavior not really standardized and can vary between versions.