These are the basic boolean operators in JavaScript: || (OR), && (AND), and ! (NOT).
The tables below show what the result will be for every combination of true and false.
||)Rule: OR is true if either side is true.
| A | B | A || B |
|---|---|---|
| true | true | true |
| true | false | true |
| false | true | true |
| false | false | false |
&&)Rule: AND is true only if both sides are true.
| A | B | A && B |
|---|---|---|
| true | true | true |
| true | false | false |
| false | true | false |
| false | false | false |
!)Rule: NOT flips a boolean value.
| A | !A |
|---|---|
| true | false |
| false | true |
Pick A and B and see the result for || and &&: