Day:9- JS- Logical Operators
Logical operators are used to combine multiple conditions in JavaScript.
They are used to combine, manipulate, or invert Boolean values (true or false).
Types of Logical Operators
- AND (&&)
- OR (||)
- NOT (!)
- Complex Expressions
1. AND Operator (&&)
The AND operator (&&) returns true only if both conditions are true.
2. OR Operator (||)
The OR operator (||) returns true if at least one of the conditions is true.
3. NOT Operator (!)
The NOT operator (!) inverts the boolean value of an expression.
4. Complex Expressions
Logical operators can be combined with parentheses to create more complex expressions.
Quick Reference Revision
Operator: AND && -Rule: ALL conditions must be true
Operator: OR || -Rule: AT LEAST ONE condition must be true
Operator: NOT ! -Rule: INVERTS the boolean value, FLIPS true to false
Operator: Complex: (), &&, ||, !, -Rule: Groups operations using parentheses for controlled order