为什么 Infinity == Infinity == 1/0 是错误的?
Why Infinity == Infinity == 1/0 is false?
问题很简单:
Infinity == Infinity
>> true
Infinity == 1/0
>> true
Infinity == Infinity == 1/0
>> false
为什么最后评价是false
?
因为Infinity == Infinity == 1/0
基本上就是
(Infinity == Infinity) == 1/0
所以
(true) == 1/0
是false
。
它看起来像下面这样..
var d = (2 == 2);
console.log(d) //true
console.log(d == 2); //[true == 2] false
comparison == return always boolean true or false
[1 or 0
]
问题很简单:
Infinity == Infinity
>> true
Infinity == 1/0
>> true
Infinity == Infinity == 1/0
>> false
为什么最后评价是false
?
因为Infinity == Infinity == 1/0
基本上就是
(Infinity == Infinity) == 1/0
所以
(true) == 1/0
是false
。
它看起来像下面这样..
var d = (2 == 2);
console.log(d) //true
console.log(d == 2); //[true == 2] false
comparison == return always boolean
true or false
[1 or 0
]