JavaScript Logical Operators
Logical operators combine true and false ideas.
They help you ask bigger questions.
Think of yes and no switches on a toy control panel.
AND
OR
NOT
Short circuiting
AND
&& means both sides must be true.
Like needing two keys to open a treasure chest.
OR
|| means at least one side must be true.
Like being allowed in if you have a pass or a friend already inside.
NOT
! flips true to false and false to true.
It is like turning a light switch the other way.
Short circuit with AND
If the left side of && is false, JavaScript can stop early.
The right side never runs.
Short circuit with OR
If the left side of || is true, JavaScript can stop early.
People use this for default values.
Tip: Read && as both. Read || as either. Read ! as opposite. Say them out loud while you code.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.