this post was submitted on 05 Aug 2025
117 points (98.3% liked)

Programmer Humor

38602 readers
52 users here now

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

Rules:

founded 6 years ago
MODERATORS
 

That's it. That's the meme.

you are viewing a single comment's thread
view the rest of the comments
[–] Mr_Fish@lemmy.world 17 points 2 months ago (2 children)
[–] Telemachus93@slrpnk.net 13 points 2 months ago

Mh, '0' is a nonempty string, so !'0' returns false. Then of course !(!'0') would return true. I'd absolutely expect this, Python does the same.

And the second thing is just JavaScript's type coercion shenanigans. In Python

bool('0') # returns True because of nonempty string
bool(int('0')) # returns False because 0 == False

Knowing that JavaScript does a lot of implicit type conversions, stuff like that doesn't strike me as very surprising.

[–] lime@feddit.nu 3 points 2 months ago

wait hang on...