0
Null & 0 value in js
Why : 0 >= null is true 0 <= null Is true But ! 0 == null Is false 0 < null Is false 0 > null Is false
3 Answers
+ 4
"The reason is that an equality check == and comparisons > < >= <= work differently. Comparisons convert null to a number, treating it as 0. Thatâs why (3) null >= 0 is true and (1) null > 0 is false.
On the other hand, the equality check == for undefined and null is defined such that, without any conversions, they equal each other and donât equal anything else. Thatâs why (2) null == 0 is false."
https://javascript.info/comparison
+ 2
There is not much point in asking WHY. Javascript has a lot of wacky behavior with implicit conversions and coercions, that affect these operators. You just have to accept that it works like this. Because the language was designed this way. :)
+ 2
in addition to Lisa
JavaScript returns undefined for null and undefined in loosely Equal (==)
https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islooselyequal