Operators are the symbols that do work on values — adding numbers, comparing them, combining true/false conditions. This lesson covers the five kinds you'll use constantly.
Used for math.
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 5 + 2 → 7 |
| - | Subtraction | 5 - 2 → 3 |
| * | Multiplication | 5 * 2 → 10 |
| / | Division | 5 / 2 → 2.5 |
| % | Remainder (modulo) | 5 % 2 → 1 |
Used to give a variable a value, often combined with a calculation.
let score = 10;
score += 5; // same as: score = score + 5
console.log(score); // 15Compare two values and produce true or false.
| Operator | Meaning |
|---|---|
| === | Equal to (checks type too) |
| !== | Not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
console.log(5 === 5); // true
console.log(5 === "5"); // false — different types
console.log(7 > 3); // trueCombine or invert true/false values.
| Operator | Meaning | Example |
|---|---|---|
| && | AND — both must be true | true && false → false |
| || | OR — at least one true | true || false → true |
| ! | NOT — flips the value | !true → false |
Work directly on the binary representation of numbers, bit by bit. You will use these far less often than the operators above, but they show up in low-level code, graphics, and permission flags.
console.log(5 & 1); // 1 — AND on the underlying bits
console.log(5 | 2); // 7 — OR on the underlying bitsBitwise operators make a lot more sense after the Binary Numbers lesson — it's fine to skim this section for now and come back to it.