2 ms·
It wouldn't be much different than in any other language, that can let you define a mutable hashable type that breaks the hashability/equality contracts needed
by berdario 12y ago
It wouldn't be much different than in any other language, that can let you define a mutable hashable type that breaks the hashability/equality contracts needed by maps. Mutating things that you'd use as keys is a well known no-no, and value equality is the expected behavior among all the developers I know. So implementing this is certainly not any less sane than other tricky behaviours already present in javascript (think equality coercions) and it would give a behavior which makes real code simpler.
On top of that, the Map implementation could always call Object.freeze() on the keys that it receives