Summary: in this tutorial, you will learn how to use JavaScript comparison operators to compare two values.
Introduction to JavaScript comparison operators
To compare two values, you use a comparison operator. The following table shows the comparison operators in JavaScript:
| Operator | Meaning |
|---|---|
| < | less than |
| > | greater than |
| <= | less than or equal to |
| >= | greater than or equal to |
| == | equal to |
| != | not equal to |
A comparison operator returns a Boolean value indicating whether the comparison is true or not. See the following example:
let r1 = 20 > 10; // true
let r2 = 20 < 10; // false
let r3 = 10 == 10; // trueCode language: JavaScript (javascript)