NaN
Not a Number
ELI5 — The Vibe Check
NaN means 'Not a Number' — it is what JavaScript gives you when math goes wrong in a weird way. Try to parse a word as a number and you get NaN. The bizarre thing: NaN is technically of type 'number' and does not equal itself. It is JavaScript's way of saying 'this math made no sense'.
Real Talk
NaN is a special numeric value defined by the IEEE 754 floating-point standard representing an undefined or unrepresentable mathematical result. In JavaScript, NaN arises from invalid number operations (parsing non-numeric strings, dividing 0/0, Math.sqrt(-1)). Crucially, NaN !== NaN by specification — use Number.isNaN() to check for it, not strict equality.
Show Me The Code
// How NaN appears:
console.log(parseInt('hello')); // NaN
console.log(0 / 0); // NaN
console.log(Math.sqrt(-1)); // NaN
console.log(undefined + 1); // NaN
// The weird part:
console.log(NaN === NaN); // false! NaN never equals itself
// Correct way to check:
console.log(Number.isNaN(NaN)); // true
console.log(isNaN('hello')); // true (coerces first — beware)
console.log(Number.isNaN('hello')); // false (strict, no coercion)
When You'll Hear This
"The calculation returns NaN — you're probably parsing a string as a number." / "Use Number.isNaN(), not isNaN() — they behave differently."
Related Terms
Float
A float is a number with a decimal point — 3.14, 1.5, -0.001. The name comes from 'floating point' because the decimal point can be anywhere.
JavaScript
JavaScript is what makes websites actually DO stuff. HTML is the bones, CSS is the skin, and JavaScript is the muscles and brain.
Null
Null means 'intentionally nothing' — a programmer chose to say 'there is no value here'. It is a deliberate absence.
Type
A type tells the computer what kind of thing a value is — is it a number, text, true/false, or a list?
Undefined
Undefined in JavaScript means a variable exists but has never been given a value.