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
[] == ![]; // true
OMG 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
-4
u/Comprehensive_Fee250 Dec 04 '25
Because == checks the physical equality. 255 is on stack, "OCaml" is on heap. Different pointers for "OCaml". Just use = if you want to compare the value. That's in the definition of "=" and "==". If you don't follow the definition and follow your intuition then the whole language is quirky. But that might be true for a lot of languages hmm.