Boolean
ELI5 — The Vibe Check
A boolean is the simplest value in programming — it is either true or false. On or off. Yes or no. 1 or 0. Named after mathematician George Boole. Every if-statement checks a boolean. Every checkbox stores a boolean. They are the building block of all logic in computers.
Real Talk
A boolean is a primitive data type with exactly two possible values: true and false. Booleans are the result of comparison operations (===, >, <) and logical operators (&&, ||, !). In JavaScript, other values are 'truthy' or 'falsy' — converted to boolean in a boolean context. Boolean logic (AND, OR, NOT) underlies all digital computation.
Show Me The Code
// Boolean values and operations:
const isLoggedIn = true;
const isAdmin = false;
// Logical operators:
console.log(isLoggedIn && isAdmin); // AND: false
console.log(isLoggedIn || isAdmin); // OR: true
console.log(!isLoggedIn); // NOT: false
// Truthy/falsy in JS (auto-converted to boolean):
if (0) { } // falsy
if ('') { } // falsy
if (null) { } // falsy
if ('hello') { } // truthy
if (42) { } // truthy
When You'll Hear This
"Return a boolean from that function." / "Check if it's truthy — JavaScript has some surprising falsy values."
Related Terms
Conditional
A conditional is an if/else decision in your code — 'if this is true, do this; otherwise, do that.' It is how your program makes choices.
Logic Error
A logic error is the sneakiest kind of bug — the code runs perfectly fine, no crashes, no errors, but it does the WRONG thing.
Null
Null means 'intentionally nothing' — a programmer chose to say 'there is no value here'. It is a deliberate absence.
Type
A type tells the computer what kind of thing a value is — is it a number, text, true/false, or a list?