r/programminghorror • • Dec 04 '25

This sub in a nutshell

Post image
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

167 comments sorted by

View all comments

17

u/piplupper Dec 04 '25

Am I too JavaScript-pilled to think all of these make sense? You just need the tripple equals === for most of these

48

u/fucking_idiot2 Dec 04 '25

i think the fact that === exists to begin with is proof of its inherent quirkiness

26

u/the_horse_gamer Dec 04 '25

javascript wasn't meant to build large apps. or god forbid, backends. it was meant to add some interactivity to a website. so the distinction between 123 and "123" didn't matter much when reading user input.

ofc, the situation is very different in the modern day

and it didn't help that the language was designed with a tight deadline.

5

u/despondencyo Dec 04 '25

Html wasn’t meant to build large apps too, it was designed for simple web pages. Now it’s a bit different xD

1

u/Holzkohlen Dec 05 '25

Meh, it's only people who have never used it complaining about it. I enjoy not having to worry about type conversion when using == and when I do care I just use ===. This is the least weird thing about JS.

10

u/AnywhereHorrorX Dec 04 '25

Just add ==== to the language already to make totally sure things are REALLY equal.

8

u/wack_overflow Dec 04 '25

Yeah and use tooling to avoid writing shit code that hits these quirks (same as every other language)

1

u/fnordstar Dec 08 '25

No, rust is not like this. Not at all.

-1

u/KagakuNinja Dec 04 '25

No, not at all "the same". I don't need tooling to compensate for Java quirks, and I don't even like Java.

0

u/LuukeTheKing Dec 04 '25

Yes, because every other language using == does it differently, so the === existing is just proof of it's major quirkiness.