Booklet
3 Logical Operators In Programming
3 LOGICAL OPERATORS IN PROGRAMMING
&&
Logical And
This operators tests more than one condition. If both expressions evaluate to true, then the expression returns true. If just one returns false, then the expression will return false.
Examples:
true && true returns true.
true && false returns false.
false && true returns false.
false && false returns true.
||
Logical Or
This operator tests at least one condition. If both expressions evaluate to true, then the expression returns true. If both return false, then the expression will return false.
Examples:
true || true returns true.
true || false returns true.
false || true returns true.
false || false returns false.
!
Logical Not
This operator takes a single boolean value and inverts it. This reverses the state of an expression. If it was false, (without the ! Before it) it would return true. If the statement was true, then it would return false.
Examples:
!true returns false.
!false returns true.