JS in the development of logical operators can be regarded as a more common operator, there are mainly three: logic and &&, logic or | | And logic is not.
When && and | | When a connection statement is made, the statements on both sides are converted to a Boolean type (Boolean), which is then performed, with the following operational rules:
1.&&
1.1 The result is true when both sides of the condition are true;
1.2 If one is false, the result is false;
1.3 When the first condition is false, the following condition is no longer judged
Note: When the numeric value participates in the logic and operation, the result is true, then the second is true, and if the result is false, the return is the first false value.
2.| |
2.1 If only one condition is true, the result is true;
2.2 The result is false when all two conditions are false;
2.3 When a condition is true, the following condition is no longer judged
Note: When a numeric value participates in a logic or operation, the result is true, the first true value is returned, and the second false value is returned if the result is false;
3..
3.1 The result is true when the condition is false, or vice versa.
Code description on:
<! DOCTYPE html>
Complementary: Logic and priority is higher than logic or;
Like Console.log (3| | 2&&5| | 0), will first calculate 2&&5 value is 5, then 3| | 5----3, finally again 3| | 0----3, so the final result is 3.