Comparison Operators

Learn how JavaScript compares values and produces true or false verdicts — the foundation of every decision your code will ever make.

Step 1 of 5

Why does code need to compare things?

Every interesting program makes decisions: Is the user old enough? Did the password match? Is the shopping cart empty? Before your code can decide anything, it needs a way to compare two values and get a yes-or-no answer. That answer is always one of two JavaScript values: `true` or `false` (called **booleans**). Comparison operators are the tools that produce those booleans.

Think of it this way: Comparison operators are like a judge at a competition — they look at two things and give a verdict: true or false. 'Is contestant A's score higher than contestant B's?' The judge doesn't change the scores; they just announce the result.
Web Standard
Comparison operators are defined in the ECMAScript specification. Every JavaScript engine — whether in Chrome, Firefox, Safari, or Node.js — follows the same rules for how comparisons work, so your code behaves identically everywhere.
Learn more on MDN
JAVASCRIPTREAD ONLY
CONSOLE
Click "Run" to execute your code...