Comparison Operators
Javascript Comparison
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 / Link | Comparing | Returns |
---|---|---|---|
== | Equal to | x == 8 | false |
== | Equal to | x == 5 | true |
=== | Strict Equal | x === "5" | false |
=== | Strict Equal | x === 5 | true |
!= | Not Equal | x != 8 | true |
!== | Strict not Equal | x !== "5" | true |
!== | Strict not Equal | x !== 5 | false |
> | Greater than | x > 8 | false |
< | Less than | x < 8 | true |
>= | Greater or Equal | x >= 8 | false |
<= | Less or Equal | x <= 8 | true |
Learn More:
Study our JavaScript Comparisons Tutorial.
Browser Support
Comparison Operators
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera |