Logical Operators

Logical Operators

  • Evaluates between two conditions/expressions and returns true or false

  • with && (Logical And) operators, both conditions have to be true in order for the whole expression to be true

  • with || (Logical Or) operators, any of the condition must be true for entire expression to be true; but if all conditions are false then the entire expression is false

Operator Description Example (all return true)
Logical AND (&&) expr1 && expr2 (3 > 1) && “cat”.length === 3
Logical OR (||) expr1 || expr2 (4 + 1) < 8 |\k

Examples

JS Bin on jsbin.com