Arithmetic
| Operator | Example | Result |
|---|
+ | 5 + 2 | 7 |
- | 5 - 2 | 3 |
* | 5 * 2 | 10 |
/ | 5 / 2 | 2.5 |
% | 5 % 2 | 1 (remainder) |
** | 5 ** 2 | 25 (power) |
Assignment
let x = 10;
x += 5; // x = x + 5 → 15
x -= 3; // 12
x *= 2; // 24
x++; // 25
Comparison
| Operator | Meaning |
|---|
=== | Equal value and type |
!== | Not equal |
> < >= <= | Greater / less than |
== | Equal after converting types (avoid) |
console.log(5 === 5); // true
console.log(5 === "5"); // false
console.log(5 == "5"); // true (surprising!)
Logical
const age = 20;
const hasTicket = true;
console.log(age >= 18 && hasTicket); // AND → true
console.log(age < 13 || hasTicket); // OR → true
console.log(!hasTicket); // NOT → false