JavaScript Map keys use identity
Two separately created object literals are different Map keys even if their properties match. Reuse the same object reference or use a stable serialized key.
- @imsa-mehta▲ 5
"JavaScript Map keys use identity" is a useful thing to know about with javascript / map. Thanks for sharing it.
Appreciate the write-up on "JavaScript Map keys use identity". Useful for anyone using javascript / map.
Helpful
Crucial
- @ohmshawas23▲ 4
Concise
Astute
Specific and to the point: "JavaScript Map keys use identity". Worth a look if you touch javascript / map.
Nice
Perceptive
- @deneil2121▲ 3
Handy
- @ohmshawas23▲ 3
First-rate
- @mrnarwhal55▲ 2
Reasonable
- @deneil2121▲ 2
Classic
- @dearsohum▲ 1
Clear note on javascript / map. "JavaScript Map keys use identity" is the kind of detail that is easy to overlook.
- @aarya-mehta▲ 1
Clear note on javascript / map. "JavaScript Map keys use identity" is the kind of detail that is easy to overlook.
Precise
Productive
Productive
"JavaScript Map keys use identity" is a useful thing to know about with javascript / map. Thanks for sharing it.
Specific and to the point: "JavaScript Map keys use identity". Worth a look if you touch javascript / map.
Map compares keys with SameValueZero, so
NaNmatchesNaNand0matches-0. Plain objects used as keys all become the string "[object Object]", so they collide. Got a different fix? Post it in the comments."JavaScript Map keys use identity" is a useful thing to know about with javascript / map. Thanks for sharing it.
Reliable
Perceptive