It may look like if a === b
is true
, then any operation using either a
or b
should give the exact same result.
But I do see an exception: 0 === -0
but 1/0
gives Infinity
and 1/-0
gives -Infinity
.
Are there any other case(s) in JavaScript this can happen?
No. According to the Strict Equality Comparison Algorithm (EcmaScript §11.9.6) this is the only exception where two different values produce true
.
However, a similar pitfall exists for the reverse situation: NaN
is an exception where calling the algorithm with the exact same value yields false
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With