Everything else is truthy. Even:
Both get converted to strings and concatenated. Not an error. Not useful. Just... weird. JavaScript’s weird parts aren’t bugs—they’re historical artifacts. Brendan Eich built this language in 10 days in 1995. It had to be flexible, forgiving, and fast.
If you’ve spent more than 48 hours with JavaScript, you’ve probably uttered the phrase: “Wait… why did it do that?” javascript weird parts
if ([]) console.log("truthy"); // Runs! if ({}) console.log("truthy"); // Runs! Empty array and empty object? Truthy. But if ([] == false) ? That’s true (see point #2). Consistency? Not today. JavaScript defines weird type coercion rules for + .
JavaScript is the most misunderstood language in the world. Some call it broken; others call it beautiful. The truth? It’s both. Everything else is truthy
These quirks are frustrating until you understand why they exist. Once you do, you stop fighting the language and start leveraging it.
console.log(typeof NaN); // "number" According to the IEEE 754 floating-point spec (which JS uses), NaN is a numeric data type that represents an invalid number. It’s a number that isn’t a number. The weirdness doesn't stop there: Not useful
const bound = show.bind({hello: "world"}); bound(); // {hello: "world"}
Rp4.000.000
Add to Cart