Skip to content

Boolean

Easy — everyone uses thisGeneral Dev

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.