2 ms·
> That would be quite the footgun Could you explain why that would be a footgun? JavaScript already has known Symbols like hasInstance which is kind of similar
by leosanchez 3y ago
> That would be quite the footgun
Could you explain why that would be a footgun? JavaScript already has known Symbols like hasInstance which is kind of similar to this.
- Gare 3y agoIt's very important to ensure that the value of hash for a given entity doesn't change if it is to be relied upon, otherwise things like Map or Set will not function properly. Therefore, one should be very careful in implementing it yourself and ideally one should use immutable hashable structures provided by the language/stdlib (like tuples or sets in Python). Until Javascript has such structures which should be enough for majority of use cases (there is record and tuple language proposal, but it's in limbo) I think it's unwise to provide a way to sloppily emulate it in user code.