0
0
Javascriptprogramming~5 mins

Logical operators in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the logical AND operator (&&) do in JavaScript?
The logical AND operator (&&) returns true if both values on its sides are true. If either side is false, it returns false.
Click to reveal answer
beginner
What is the result of true || false in JavaScript?
The result is true because the logical OR operator (||) returns true if at least one side is true.
Click to reveal answer
beginner
Explain the logical NOT operator (!) in JavaScript.
The logical NOT operator (!) reverses the truth value. If the value is true, it becomes false; if false, it becomes true.
Click to reveal answer
intermediate
What will false && (anything) evaluate to and why?
It will evaluate to false immediately because with AND, if the first value is false, the whole expression is false without checking the second value.
Click to reveal answer
intermediate
How does short-circuit evaluation work with logical OR (||)?
With OR (||), if the first value is true, JavaScript does not check the second value because the whole expression will be true anyway.
Click to reveal answer
What is the result of true && false?
Atrue
Bfalse
Cundefined
Dnull
Which operator returns true if at least one operand is true?
A||
B!
C&&
D===
What does the expression !false evaluate to?
Atrue
Bfalse
Cnull
Dundefined
In false && someFunction(), will someFunction() be called?
AOnly if someFunction returns false
BYes, always
COnly if someFunction returns true
DNo, because of short-circuit
What is the result of true || false?
Anull
Bfalse
Ctrue
Dundefined
Explain how the logical AND (&&) and OR (||) operators work in JavaScript, including short-circuit behavior.
Think about when JavaScript stops checking the second value.
You got /3 concepts.
    Describe the effect of the logical NOT (!) operator on a boolean value.
    It flips the truth value.
    You got /3 concepts.