33.1.2 states, regarding a copy of a Map using the constructor, "That copy is shallow: keys and values are the same; they are not duplicated."
This implies copy by reference rather than by value for key/value pairs, so I expected to find the following:
map = new Map().set('foo', 'bar');
copy = new Map(map);
copy.set('foo', 'baz');
assert.deepEqual(map, copy);
This does not (thankfully?) seem to happen: changing the value of something in copy does not affect map.
It seems to me this may be an ambiguity of human language issue - I would say that in this case the keys and values were duplicated. Specifically stating that key/value pairs are copied by value rather than by reference would remove this ambiguity.
33.1.2 states, regarding a copy of a Map using the constructor, "That copy is shallow: keys and values are the same; they are not duplicated."
This implies copy by reference rather than by value for key/value pairs, so I expected to find the following:
This does not (thankfully?) seem to happen: changing the value of something in
copy
does not affectmap
.It seems to me this may be an ambiguity of human language issue - I would say that in this case the keys and values were duplicated. Specifically stating that key/value pairs are copied by value rather than by reference would remove this ambiguity.