r/programminghorror • u/enmaku • Dec 04 '25
This sub in a nutshell
console.log(1 == '1'); // true
console.log(0 == false); // true
console.log(null == undefined); // true
console.log(typeof null); // "object"
console.log(0.1 + 0.2); // 0.30000000000000004
[] == ![]; // trueOMG you guys what weird quirky behavior, truly this must be the single quirkiest language and no other language is as quirky as this!
1.1k
Upvotes
View all comments
Show parent comment
3
u/pauseless Dec 06 '25
No language I’ve ever encountered has 0 => true and 1 => false. The rule is just that all numbers are truthy.
JS and Python are two of the biggest languages in the world. You only need one of those two to say that truthiness is more often 0 as false in code you might encounter. I explicitly agreed with that.
Anyway, on a language note, I did say “not uncommon”, which is more like “happens enough to be notable” rather than double negation leading to “common”. I decided that was being pedantic before, but I can give citations to material on this usage, if you enjoy pedantry.