Falsy
ELI5 — The Vibe Check
Falsy values are the six (well, seven) values in JavaScript that evaluate to false in a boolean context: false, 0, empty string, null, undefined, and NaN. Plus -0 and 0n if you're counting. Everything else is truthy. The classic bug: checking if (count) when count is 0 — it's falsy even though 0 is a perfectly valid number.
Real Talk
Falsy values in JavaScript are values that coerce to false in boolean contexts. The complete list: false, 0, -0, 0n (BigInt zero), '' (empty string), null, undefined, and NaN. Common bugs arise from falsy checks on valid zero values or empty strings. The nullish coalescing operator (??) was introduced specifically to distinguish null/undefined from other falsy values.
Show Me The Code
// All falsy values
Boolean(false) // false
Boolean(0) // false
Boolean('') // false
Boolean(null) // false
Boolean(undefined) // false
Boolean(NaN) // false
// The classic bug:
const items = 0
if (items) { /* never runs, even though 0 items is valid */ }
if (items != null) { /* correct way to check */ }
When You'll Hear This
"Zero is falsy — that's why the counter disappears when it hits 0." / "Use strict equality (===) to avoid falsy surprises."
Related Terms
Footgun
A feature or tool that makes it really easy to shoot yourself in the foot — meaning it's easy to make a mistake that hurts you.
JavaScript
JavaScript is what makes websites actually DO stuff. HTML is the bones, CSS is the skin, and JavaScript is the muscles and brain.
Truthy
In JavaScript, truthy means 'not technically true, but close enough.' The number 42 is truthy. The string 'hello' is truthy.
TypeScript
TypeScript is JavaScript with a strict parent watching over it.