Boolean algebra is the branch of logic that deals with only two values — true and false — and the operations that combine them. It's the mathematical foundation behind every if statement and logical operator you write, and behind how digital circuits themselves are built.
| Operation | JavaScript | Result is true when |
|---|---|---|
| AND | && | Both inputs are true |
| OR | || | At least one input is true |
| NOT | ! | The input is false (it flips the value) |
A truth table lists every possible combination of inputs and the result for each — a compact way to see exactly how an operation behaves.
| A | B | A && B | A || B |
|---|---|---|---|
| true | true | true | true |
| true | false | false | true |
| false | true | false | true |
| false | false | false | false |
Every condition you write — if (age >= 18 && hasId) — is boolean algebra in action. Understanding the truth tables makes it much easier to write correct conditions, especially once you start combining several with && and || in the same line.