Boolean
In one line
A boolean is a value that can only be true or false — used for making decisions in code.
In simple words
A boolean is the simplest data type: it has exactly two possible values, true or false. Booleans are the foundation of conditional logic — the "if this, then that" reasoning that lets programs make decisions.
You get boolean values from comparisons (5 > 3 is true, 10 === 20 is false) and from functions that answer yes/no questions (isLoggedIn(), isValid(email)). They are also stored in flags like isReady or hasError to track on/off state.
Booleans combine with logical operators like AND (&&), OR (||), and NOT (!) to build complex conditions. For example, if (isLoggedIn && hasPermission) runs only when both are true.
Example
let isAdult = true;
let hasLicense = false;
console.log(isAdult && hasLicense); // false
console.log(isAdult || hasLicense); // true
console.log(!isAdult); // falseBooleans combine with && (AND), || (OR), and ! (NOT) to build conditions.
Related terms
Related Resources
Related Lessons
- Conditions
Booleans drive if/else decisions
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.