- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Truthy and Falsy
JavaScript Type System
JavaScript Truthy and Falsy
Every JavaScript value is either truthy or falsy when used as a condition.
There are only eight falsy values; everything else is truthy.
Learning that short list is one of the highest-value things you can memorise.
Example
Example
javascript
if ("hello") {
console.log("a non-empty string is truthy");
}
if (!"") {
console.log("an empty string is falsy");
}Both messages are printed.
