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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.