← Back to Roadmap

Truthy & Falsy Values

Easy

In plain terms

Falsy: false, 0, -0, "", null, undefined, NaN. Everything else is truthy. Used in if, &&, ||. Be careful with 0 and "".

What you need to know

  • 6 falsy values
  • 0 and "" are falsy
  • [] and {} are truthy

Try it yourself

Copy the code below and run it in your browser console or a code editor:

if (0) {}  // falsy
if ('') {} // falsy
if ([]) {} // truthy!
if ({}) {} // truthy!

Learn more

Dive deeper with these trusted resources: