Comparisons
Equal, bigger, smaller.
Comparisons ask questions about values, and answer with true or false. Is this bigger? Are these equal? They're the building blocks of every decision a program makes.

- Questions about values
- true or false
- Building blocks of decisions
Comparison operators
Less than, and greater than. Less than or equal, and greater than or equal. Three equals signs check that two values are exactly equal. And exclamation mark, equals, equals checks that they're different. Strings can be compared too. Run it.
console.log(5 < 10, 5 > 10);
console.log(10 <= 10, 9 >= 10);
console.log(7 === 7, 7 === 8);
console.log(7 !== 8);
console.log("apple" === "apple", "apple" < "banana");true false true false true false true true true
One, two, or three equals
One equals sign stores a value in a variable. It's not a question. Three equals signs ask, are these exactly the same? Mixing them up is one of the most common beginner bugs. And yes, there's also a two equals version. Next lesson, we'll see why you should avoid it.
| key | value |
|---|---|
| = | store a value |
| === | exactly equal? |
| !== | different? |
| == | avoid, see next |
Summary
Comparisons give true or false. Use three equals to check equality, and one equals to assign. Next, why three equals is better than two.
Key takeaways- < > <= >=
- === and !==
- = assigns