Comparison and Logical Operators
Comparison and Logical operators are used to test for true or false.
Comparison Operators
JavaScript supports the following comparison operators:
Operator | Description |
---|---|
== |
is equal to |
=== |
is exactly equal to
(value and type) |
!= |
is not equal |
> |
is greater than |
< |
is less than |
>= |
is greater than or equal to |
<= |
is less than or equal to |
Logical Operators
JavaScript supports the following logical operators:
Operator | Description |
---|---|
&& |
and |
|| |
or |
! |
not |
Conditional Operator
JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. This operator has the form:
variablename = (condition)
?value1
:value2