3 min read
Boolean Values
Prerequisites: Data types
A boolean is a value that's either true or false, always lowercase
in JavaScript. Booleans are what conditions and comparisons are built
from.
const isRaining = true;
console.log(5 > 3); // true
console.log(5 === "5"); // false — different types never equal with ===
Common mistakes
- JavaScript treats several non-boolean values as "falsy" in a
condition —
0,"",null,undefined, andNaNall act likefalse. Everything else (including"0"and[]) is "truthy."