__3.2 Logical Operators__

## What Are Logical Operators?

Logical operators are used to combine two conditionals. JavaScript includes the following logical operators.

Name | Purpose |
---|---|

&& | (AKA the `AND` Operator)
Checks whether two operands are `non-zero` . If one operand is `zero` then this operator returns 0 or `false` and 1 or `true` otherwise.
(Note: 0, false, undefined, null, or "" is considered `"zero"` ) |

|| | (AKA the `OR` Operator)
Checks whether any one of the two operands is `non-zero` . If ALL operands are `zero` then this operator returns 0 or `false` and 1 or `true` otherwise.
(Note: 0, false, undefined, null, or "" is considered `"zero"` ) |

! | (AKA the `NOT` operator) It reverses the Boolean result of the operand or condition. |

## Examples

```
let a = 5, b = 10;
(a != b) && (a < b); // returns true
(a > b) || (a == b); // returns false
(a < b) || (a == b); // returns true
!(a < b); // returns false
!(a > b); // returns true
```

__Previous Section__

3.1 Relational Operators

__Next Section__

3.3 If, Else, Else if

**Copyright © 2021 Code 4 Tomorrow. All rights reserved.**
The code in this course is licensed under the MIT License.
*If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact **classes@code4tomorrow.org** for inquiries.*