I am stuck with this peculiar scenario mentioned below. Could someone please explain to me what's the reason for the following behavior.
Why is Infinity - Infinity
results NaN, but NaN === (Infinity-Infinity)
results false
?
I am stuck with this peculiar scenario mentioned below. Could someone please explain to me what's the reason for the following behavior.
Why is Infinity - Infinity
results NaN, but NaN === (Infinity-Infinity)
results false
?
The answer lies in the full form of NaN.
NaN stands for Not a Number.
Hence, if something is not a number, it cannot be compared or checked for equality.
Going mathematically,
Infinity - Infinity = NaN (1)
NaN == Infinity - Infinity (2)
Here in (1) NaN holds a value that signifies the result is not quantifiable.
And in (2) you are checking the equality of 2 entities that are not quantifiable.
Hope that makes sense.
P.S. I know string values can be compared, but that is not the case with NaN.