Skip to content

Boolean

In one line

A boolean is a value that is either true or false, used for logical operations and conditionals.

In simple words

A boolean is a primitive value that is either true or false. Booleans are the foundation of conditional logic — if statements, while loops, and ternary operators all depend on boolean values.

JavaScript has six falsy values: false, 0, "" (empty string), null, undefined, and NaN. Everything else is truthy. This means if ("hello") is true and if (0) is false.

Comparison operators (===, <, >, <=, >=) return booleans. Logical operators (&&, ||, !) combine or invert boolean values. The Boolean() function converts any value to its boolean equivalent.

Example

javascript
const isAdult = true;
const hasLicense = false;
console.log(isAdult && hasLicense); // false
console.log(isAdult || hasLicense);  // true
console.log(!isAdult);               // false

Logical operators combine boolean values for conditional logic.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary