You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the >= operator in fact works in a very different way, which is basically to take the opposite of the < operator
That's not ture, >= and <= operators just convert both sides to numbers if they have different types and that's why null >= 0 returns true because 0 == 0 is true.
You can test that withNaN and will return false :
NaN == 0 // false
NaN > 0 // false
// But ...
NaN >= 0 // false
You can see that NaN < 0 returns false and >= operator doesn't return the opposite.
So >= and <= operators are just shorthands : x >= y → x > y || x == y x <= y → x < y || x == y
and if x and y have different types they will be converted to numbers before comparing.
The text was updated successfully, but these errors were encountered:
That's not ture,
>=
and<=
operators just convert both sides to numbers if they have different types and that's whynull >= 0
returns true because0 == 0
is true.You can test that with
NaN
and will return false :You can see that
NaN < 0
returns false and>=
operator doesn't return the opposite.So
>=
and<=
operators are just shorthands :x >= y
→x > y || x == y
x <= y
→x < y || x == y
and if
x
andy
have different types they will be converted to numbers before comparing.The text was updated successfully, but these errors were encountered: