Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values. In this table, the x-variable has a value of 5 to explain the JavaScript Comparison operators:
Operator | Description | Comparing | Returns |
---|---|---|---|
== | is equal to | x==8 | false |
x==5 | true | ||
!= | is not equal to | x!=8 | true |
> | is greater than | x>8 | false |
< | is less than | x<8 | true |
>= | is greater than or equal to | x>=8 | false |
<= | is less than or equal to | x<=8 | true |