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:
console.log(isNaN(NaN)); // true // But wait... console.log(isNaN("hello")); // true (because "hello" can't be a number) That’s why ES6 gave us Number.isNaN() which actually behaves. In many languages, if you forget to declare a variable, you get an error. In JavaScript (non-strict mode), you get a present : js the weird parts
function oops() { accidentalGlobal = "I'm everywhere now"; } oops(); console.log(window.accidentalGlobal); // "I'm everywhere now" You didn't use var , let , or const ? Congratulations, you just polluted the global object. This is why we have linters and "use strict" . The this keyword is like a chameleon on caffeine. Its value depends entirely on how a function is called. console
const bound = showThis.bind("hello"); bound(); // String {"hello"} The only reliable way to check for NaN is: console