The Logical AND Operator: &&
The logical AND operator, written &&, also combines two expressions into one. The resulting expression has the value true only if both of the original expressions are true. Here are some examples:
5 == 5 && 4 == 4 // true because both expressions are true5 == 3 && 4 == 4 // false because first expression is false5 > 3 && 5 > 10 // false because second expression is false5 > 8 && 5 < 10 // false because first expression is false5 < 8 && 5 > 2 // true because both expressions are true5 > 8 && 5 < 2 // false because both expressions are false
Because the && has a lower precedence than the relational operators, you don’t need to use parentheses in these expressions. Like the || operator, the && operator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access