What are truthy and falsy values in JavaScript?

In a condition JavaScript treats every value as true or false. The falsy values are: false, 0, "", null, undefined and NaN. Everything else is truthy.

console.log(Boolean(""));
console.log(Boolean("0"));
console.log(Boolean([]));
console.log(Boolean(0));

Output:

Tutorials Class - Output Window

false
true
true
false

See Type Conversion.


Learn more about the similar topics:
Tutorials
JavaScript Variables
JavaScript Scope
JavaScript Data Types
JavaScript Type Conversion
JavaScript Operators
JavaScript Numbers and Math
Exercises & Assignments
Write a JavaScript program to add two numbers
Write a JavaScript program to swap two variables
Interview Questions & Answers
What are the data types in JavaScript?
What is the difference between == and === in JavaScript?
What is NaN in JavaScript?
What is the difference between null and undefined?
What is scope in JavaScript?
What is the difference between var, let and const?
What is hoisting in JavaScript?