New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map with keys of any type #30
Comments
as with any js object {} !== {}. Referential equality |
This is true. I should make a mention that we are no longer limited to strings, but we can only effectively use maps with primitive values. I'll go ahead and update the example to make note of this. Much appreciated! 👍 |
Uh, good. Thanks for handling this so quickly. 👍 In case people might want to nitpick: I tried to be careful in my choice of words:
As opposed to equality for non-primitives (by) reference, which is (should be?) well defined, much simpler to implement, but not what people want in most cases. It actually seems like the ES standard doesn't talk about "reference equality" and "value equality", so I don't think that people would get confused if we're not using that terminology... I just felt like I should mention it |
While technically correct (you can insert them and enumerate through all the values in a Map/Set), "use any type" ignores the fact that you cannot actually query a Map for keys of any type
This might give people misconceptions, since it overlooks the fact that EcmaScript doesn't define equality for non-primitive values.
That is
map.get({})
ormap.get(function () {})
will give you backundefined
(You'd have the same problem withArray
,Date
and any other object)For this reason, people might want to use a library that actually shoulder that burden like:
(and, as an added bonus, the structures these libs define are immutable)
The text was updated successfully, but these errors were encountered: