Logical operators

Inversion

The inversion operator (!) returns true if the operand is false, and false if the operand is true:

Example

!true //false
!false //true

Logical and

The and or && expression determines if two values are both true. It returns true if both values are true and false otherwise:

Example

true && false // false
true and true  // true

Logical or

The or or ||expression determines if either of the values (or both) are true. It returns true if one (or both) of the values are true.

Example

false or false // false
true || false  // true 

Last updated