JavaScript Logical Operators: Truth Tables

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.

1. OR (||)

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

2. AND (&&)

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

3. NOT (!)

Rule: NOT flips a boolean value.

A !A
true false
false true

Interactive Demo

Pick A and B and see the result for || and &&:

A:
B:
A = true
B = false
A || B = true
A && B = false
!A = false