1

I can't find a rational explanation on that:

null > 0   // as expected
false

null == 0  // as expected
false

But

null >= 0
true

From my understanding null is "nothing", it is non-measurable. So using a comparison operator with zero should return false or NaN or something similar. Can somebody explain me why the js has implement this rule with that way?

Daedalus
  • 295
  • 2
  • 17
  • 3
    Javascript type coercion is the reason https://medium.freecodecamp.org/js-type-coercion-explained-27ba3d9a2839 – anuragb26 Jan 10 '19 at 18:14
  • 1
    to be short, when you use `>` or `<` js turn null to 0, so `0 > 0` is false but `0 >= 0` is true – Emeeus Jan 10 '19 at 18:32
  • JS sends realtional Operators through an Abstract Relational Comparison Algorithm. Which says on a high level if null < 0 is false, then null >= 0 is true https://blog.campvanilla.com/javascript-the-curious-case-of-null-0-7b131644e274 – Friedrich Siever Jan 10 '19 at 18:37

0 Answers0