今天从同事那里了解一个有趣的js
var a =[];
alert(a == !a);
结果为true。
右边a是一个空数组,为truth,运算符优先!a为false,相当于0
左边a跟0做比较时,隐式转换为0,所以结果为true。
java中其实也有这样的等式
float a = float.NaN
a != a 也为true
因为float.NaN是个不确定的数有一定范围
If the argument is any value in the range
* <code>0x7ff0000000000001L</code> through
* <code>0x7fffffffffffffffL</code> or in the range
* <code>0xfff0000000000001L</code> through
* <code>0xffffffffffffffffL</code>, the result is a NaN.//对NaN的注释
对于两个不确定的数 a != a 就为true了