Comparison Operators
Javascript Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values.
Given that x = 5, the table below explains the comparison operators:
Oper | Name | Comparing | Returns | Try it |
---|---|---|---|---|
== | equal to | x == 8 | false | Try it » |
== | equal to | x == 5 | true | Try it » |
=== | equal value and type | x === "5" | false | Try it » |
=== | equal value and type | x === 5 | true | Try it » |
!= | not equal | x != 8 | true | Try it » |
!== | not equal value or type | x !== "5" | true | Try it » |
!== | not equal value or type | x !== 5 | false | Try it » |
> | greater than | x > 8 | false | Try it » |
< | less than | x < 8 | true | Try it » |
>= | greater or equal to | x >= 8 | false | Try it » |
<= | less or equal to | x <= 8 | true | Try it » |
For a tutorial about comparison operators, read our JavaScript Comparisons Tutorial.
See Also:
Arithmetic Operators (+ - * /)
The Exponentiation Operator (**)
The Remainder Operator (%)
The Increment Operator (++)
The Decrement Operator (--)
Browser Support
Comparison Operators
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |