Possible Duplicate:
Why `null >= 0 && null <= 0` but not `null == 0`?
All suppose to be true:
alert( "null==undefined: " + (null == undefined) )
alert( "null==0: " + (null == 0) ) // why false??
alert( "false=='': " + (false == '') )
alert( "true==1: " + (true == 1) )
alert( "true=='1': " + (true == '1') )
alert( "'1'==1: " + ('1' == 1) )
All suppose to be false:
alert( "null===undefined: " + (null === undefined) )
alert( "null===0: " + (null === 0) )
alert( "false==='': " + (false === '') )
alert( "true===1: " + (true === 1) )
alert( "true==='1': " + (true === '1') )
alert( "'1'===1: " + ('1' === 1) )
Why (null == 0) is false
I use last chrome to test it.
The null type is not really comparable with the number type, so the comparison algorithm returns false. From the spec (omitted the associative cases):
null == undefined is trueType(null) is Null, not an object (as in the typeof operator).return 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