DEV Community

Cover image for Truthy and Falsy Values in JavaScript
Abhishek Rath
Abhishek Rath

Posted on • Updated on

Truthy and Falsy Values in JavaScript

Before diving into truthy and falsy values, let us understand what boolean data type is in JavaScript?

A JavaScript Boolean denotes one of two values: true or false.
For example,
Boolean Example

Boolean() function can be used to find out if an expression (or a variable) is true or false.

Now let us know about truthy and falsy values.

Falsy Values

  • Falsy values are the values that are not actually false but will produce the result as false when converted into boolean.
  • There are total 5 falsy values in JS - 0, undefined, NaN, null, '' . Falsy

Truthy Values

  • Truthy values are the values that are considered true when converted into Boolean.
  • All values except false, 0, undefined, NaN, null, '' are truthy values.

Truthy

I hope you find this article simple and easy to understand JavaScript truthy and falsy values.

Top comments (0)