Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I think it's because the <= and the >= operators look at being not the reciprocal. So if you're asking null <= 0 then JavaScript checks if null is contained in the set > 0. Since that's a no, then it's true.
I might be way off though -
epse36617y@dongerzone absolutely you are damn right! Calculating the smaller or greater than is a whole lot of steps but it ends up just returning the default false and the <= operator is true if > is false
-
The < operator and family create a total order, so every value will be either < or >= every other value. This allows safely sorting on < even when values are of mixed types.
null < 1
null > -1 -
@Faraaz it's basically Chromium plus a free VPN.
Also I work with WebVR and Chrome had some issues with its flags. Easier to use opera than debug Chrome flags -
th3113397yI would ++, but that is a shocking photo, even for one inexplicably taken with a phone.
-
theuser48027y@Greggergalactic A null gets implicitly converted to a number? What the actual fuck?
-
@Greggergalactic The reason I hate weakly typed languages
These sort of implicit type conversions in JavaScript is what makes me rant about it.
Sadly, I cannot not use it because of its dominance in web development. My only other option is typescript and I'm not at the liberty of using it.
A good programming language should at least throw a warning about this. Things like this is what will make developers pull out their hair because mathematically and logically, this is very illogical -
meowth4297y==, >= and =< cause type coercision. This is why JS the good parts and all books on JavaScript say you should use === of course you're out of luck for >= and <=. It would cause quite ambiguous behavior.
-
theuser48027y@Greggergalactic In Python 3.5, the result of "None >= 0" is a TypeError: unorderable types. I don't understand why JS will actually "change" a null value before comparing, that's terrible.
Throwing an error or issuing a warning makes sense and that's how it should be.
WHY U DO DIS JAVASCRIPT
undefined
illogical
javascript
why?