What are truthy and falsy values in JavaScript?

Answer

In JavaScript, every value has an inherent boolean value used in boolean contexts (if statements, logical operators). Falsy values are the six values that evaluate to false: false, 0 (and -0 and 0n), "" (empty string), null, undefined, and NaN. Everything else is truthy — including: true, any non-zero number, any non-empty string (even "false" or "0"), objects (even empty ones {}), arrays (even empty ones []), and functions. This enables concise patterns: if (user) { }, const name = user.name || "Guest". The nullish coalescing operator (??) only treats null and undefined as falsy (not 0 or ""), which is often more appropriate for default values.