3 ms·
The === operator is a coercion-free equality operator. It's not an object identity comparison operator.
by kccqzy 8y ago
The === operator is a coercion-free equality operator. It's not an object identity comparison operator.
- XCSme 8y agoBut for `Objects` (not primitves) it is the identity comparison operator, right?
- kccqzy 8y agoI wasn't aware of that. I thought ES2015 added Object.is() for this purpose: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- AgentME 8y agoThe main difference between === and Object.is() is that === treats +0 and -0 as equivalent, despite the fact that some math operations treat them differently. I think they added Object.is() because it was awkwardly difficult to make code tell the difference between +0 and -0.
- scottmf 8y agoYes
- ZenPsycho 8y agotechnically for primatives too, since they are interned, immutable and their value is their identity?