Js The Weird Parts Guide

So next time you see [] + [] returning "" , don’t cry. Laugh. Then fix it. And remember: you’re not alone. What’s the weirdest JavaScript bug you’ve ever encountered? Hit reply or drop a comment—I’d love to compare war stories.

function showThis() { console.log(this); } showThis(); // window (or undefined in strict mode) js the weird parts

console.log(typeof NaN); // "number" Yes. The representation of "Not a Number" is technically a number. And as we saw, it refuses to be friends with anyone, including itself. The only reliable way to check for NaN is: So next time you see [] + [] returning "" , don’t cry