Truthy and Falsy Values in JavaScript

Srijan } Author Pic
SrijanJan 26, 2025 - JavaScript
Truthy and Falsy Values in JavaScript - Reacted Node

Photo: Angela Roma/Pexels

When a value is truthy in Javascript, it does not means that the value is equal to true but it means that the value coerces to true when evaluated in a boolean context.

1function truthyOrFalsy(value) {
2 if (value) {
3 console.log("Truthy Value");
4 } else {
5 console.log("Falsy Value");
6 }
7}

The above function evaluates the passed value in a Boolean Context(if condition) and checks if whether the passed value is truthy or falsy.

Falsy Values

Most of the values in javascript are Truthy, so it is better to list the Falsy value where we have only a limited number of cases. There are a total of 8 falsy values in Javascript:

  • undefined
  • NaN
  • null
  • false
  • "" (Empty String)
  • 0 (0 is an alias for +0)
  • -0
  • 0n (BigInt)

We can validate whether the above values are falsy or not by passing them as a parameter to the truthyOrFalsy function we defined at the starting of this article.

1truthyOrFalsy(undefined); // Falsy Value
2truthyOrFalsy(NaN); // Falsy Value
3truthyOrFalsy(null); // Falsy Value
4truthyOrFalsy(""); // Falsy Value
5truthyOrFalsy(false); // Falsy Value
6truthyOrFalsy(0); // Falsy Value
7truthyOrFalsy(-0); // Falsy Value
8truthyOrFalsy(0n); // Falsy Value

Truthy Values

Despite we might think that the empty array( [] ) or empty object( ) should be falsy values, but they are actually truthy values in Javascript.

1truthyOrFalsy([]); // Truthy Value
2truthyOrFalsy({}); // Truthy Value
3
4//some more truthy values
5truthyOrFalsy(42); // Truthy Value
6truthyOrFalsy(new Date()); // Truthy Value
7truthyOrFalsy("Welcome"); // Truthy Value