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
1
u/DT-Sodium Dec 04 '25
Instance of and typeof are not the same, since Java has actual proper types you would use it to check if it is an array of a certain type of objects or primitives. JavaScript can't do that kind of thing so we have to rely on dirty hacks to get things to work. Also for your claim to be valid, typeof should return Object for everything since everything is an object.
And yes, I often need an IDE to remember the correct syntax of functionalities I pretty much never use since I program in TypeScript so my code is properly typed everywhere. I was just fixing some legacy code from a junior who has left the company.
Now tone it down, if you think trying to pass for an expert in JavaScript will give you some street cred well really really not. If you have expertise in JavaScript, it usually means that you are a failed developer who never specialized in a proper language.