In JavaScript, in what situation (s) is === b, but using a or b can give different results?

It might seem that if a === b is true , then any operation using a or b should give the same result.

But I see an exception: 0 === -0 , but 1/0 gives Infinity and 1/-0 gives -Infinity .

Is there any other case in JavaScript that could happen?

+6
source share
1 answer

No. According to the strict equality comparison algorithm (EcmaScript §11.9.6) this is the only exception where two different values ​​produce true .

However, there is a similar error for the reverse situation: NaN is an exception when calling an algorithm with exactly the same value gives false .

+5
source

All Articles