Truthy and falsy values

In JavaScript, every value is evaluated as true (truthy) or false (falsy) in a boolean context. The falsy values are false, 0, -0, 0n, '', null, undefined, and NaN. All others are truthy, including '0', [], and {}.

Example

if ([]) console.log('truthy')  // is displayed

Related concepts

The whole glossary