The Boolean Type and Its Two Values
You'll learn: What the Boolean type is and how true and false form the foundation of all decision-making in JavaScript.
What Are Booleans?
In JavaScript, a Boolean is the simplest data type — it can only be one of two values: true or false. Think of it like a light switch: it's either ON or OFF, with no in-between state.
Booleans are named after mathematician George Boole, who created a system of logic based on binary values. In programming, Booleans let your code make decisions, answer yes/no questions, and control which parts of your program should run.
The Two Values
true // Boolean value representing "yes", "on", or "correct"
false // Boolean value representing "no", "off", or "incorrect"
Notice that true and false are keywords written in all lowercase letters — they're not strings, so they have no quotes around them. They're primitive values built directly into the language.
Why Booleans Matter
Every decision your code makes ultimately comes down to something being true or false. Is the user logged in? Is the shopping cart empty? Should this button be clickable? All these questions get answered with Boolean values.
let isLoggedIn = true;
let hasCompletedProfile = false;
Key Takeaway: JavaScript's Boolean type has exactly two possible values: true and false — these simple values power all conditional logic and decision-making in your programs.