Javascript Weird Parts !!top!! May 2026
const obj = { show }; obj.show(); // obj
JavaScript is the most misunderstood language in the world. Some call it broken; others call it beautiful. The truth? It’s both. javascript weird parts
Let’s pop the hood and explore the —the quirks that make you scratch your head, and ultimately, make you a better developer. 1. typeof NaN === "number" (Excuse me?) You try to parse an integer from a string like "hello" . You get NaN (Not-a-Number). You ask JavaScript what type it is: const obj = { show }; obj
Arrow functions don't have their own this —they inherit from the parent scope. That’s often a lifesaver, but it’s another thing to memorize. Every value in JS is inherently truthy or falsy. There are exactly 8 falsy values : It’s both
Put { on the same line as return . 6. this – The Shape-Shifter In most languages, this is predictable. In JavaScript, it depends on how you call the function.
console.log(1 + "2"); // "12" (string) console.log(1 + 2 + "3"); // "33" (evaluates left to right: 3 + "3") console.log([] + []); // "" (empty string) console.log([] + {}); // "[object Object]" console.log({} + []); // 0 (Wait, run this in a console... yes, 0) The last one is a parsing edge case where {} is interpreted as an empty code block, not an object. This one angers accountants and mathematicians equally.