Javascript Weird: Parts

Everything else is truthy. Even:

false , 0 , -0 , 0n (BigInt zero), "" , null , undefined , NaN . javascript weird parts

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: Everything else is truthy

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 a number that isn’t a number

function show() { console.log(this); } show(); // window (or global in Node) new show(); // {} (the new instance)

const obj = { show }; obj.show(); // obj

function getObject() { return { value: 42 } } console.log(getObject()); // undefined