JavaScript Logical Operators | JavaScript Logical Tutorial By WDH

JavaScript Logical Operators


JavaScript Logical Operators
Logical expressions are evaluated from left to right. They tested for possible “short-circuit” evaluation using the following rules:
  • False &&(don’t care exp) is short-circuit evaluated to false
  • True //(don’t care exp) is short-circuit evaluated to true
  • Note that “don’t care exp” is not evaluated
The Logical operators are as shown below:
 
Operator
Description
Example
&&
Logical AND: true if both the operands are true, else returns false
a&&b
||
Logical OR: true if either of the operands is true; returns false if both are false
a||b
!
Logical NOT: true if the operand is false and vice-versa.
!a
 
Example
Output