this post was submitted on 16 Jun 2023
38 points (95.2% liked)

Programmer Humor

32061 readers
1070 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Bjoern_Tantau@feddit.de 0 points 1 year ago (2 children)

Can someone explain this? I mean, the last result. Usually I can at least understand Javascript's or PHP's quirks. But this time I'm stumped.

[–] mycus@kbin.social 1 points 1 year ago* (last edited 1 year ago) (1 children)

JS null and undefined shenanigans


basically:

  1. bigger an lesser comparison types convert null to zero, so is zero bigger than zero? no
  2. == is fucky and to it null only equals undefined and undefined only equals null, so no
  3. is zero bigger than or equal to zero? yeah
[–] Bjoern_Tantau@feddit.de 0 points 1 year ago (1 children)

Ugh, thanks, of course. Stupid brain.

[–] mycus@kbin.social 1 points 1 year ago (1 children)

I'm starting to think JS maintainers have a thing against mathematicians

[–] Quik2007@kbin.social 1 points 1 year ago

more likely against humans

[–] omnislayer88@kbin.social 1 points 1 year ago

My only thought here might be >= is usually the same as !< and maybe thats how it is defined in javascript and since < is false than >= == !false == true