The difference between && and || is that the && operator returns true when both operands are true, whereas the || operator returns false when both operands are false.
The following truth table shows the difference between && and ||:
|x||y||x && y||x || y|
Note: && is logical AND operator. || is logical OR operator.
Another difference between && and || is that the && operator has higher precedence than the || operator.
let x = true, y = false, z = true; console.log(x || y && z); //true
y && z is evaluated, and it gave
false. After that,
x || false is computed, resulting in
true. So, the overall value of the expression is