Boolean Literals in Code
What you'll learn: How to write the two Boolean values in JavaScript and use them in your code.
The Two Boolean Literals
In JavaScript, there are exactly two Boolean literals: true and false. These are special keywords (not strings, not numbers) that represent truthfulness and falseness.
Think of them like binary switches: a light is either on (true) or off (false). There's no in-between state for a Boolean value.
Writing Boolean Literals
You write them exactly as shown—all lowercase, no quotes:
true // The literal for "true"
false // The literal for "false"
Important: These are NOT strings. Writing "true" (with quotes) creates a string containing the word "true", not an actual Boolean value.
Using Booleans in Variables
You can assign Boolean literals directly to variables:
let isLoggedIn = true;
let hasPermission = false;
let gameOver = true;
Booleans in Expressions
Boolean literals can appear anywhere you need a true/false value:
let userActive = true;
let systemReady = false;
// You can reassign them
userActive = false;
// You can use them in comparisons
let same = (userActive === false); // true, because both are false
Key Takeaway: JavaScript has exactly two Boolean literals—true and false—written in lowercase without quotes. They represent the fundamental concept of truthfulness in your code and can be assigned to variables or used directly in expressions.