Operators are the symbols JavaScript uses to perform actions on values — doing math, assigning values to variables, comparing two things, or combining logical conditions. Most of them will look familiar from basic math, but a few have JavaScript-specific behavior worth knowing well.
Arithmetic Operators
console.log(10 + 3); // 13 — addition
console.log(10 - 3); // 7 — subtraction
console.log(10 * 3); // 30 — multiplication
console.log(10 / 3); // 3.3333333333333335 — division
console.log(10 % 3); // 1 — remainder (modulus)
console.log(10 ** 2); // 100 — exponentiation (10 squared)
Output:
13
7
30
3.3333333333333335
1
100
Assignment Operators
let score = 10;
score += 5; // same as score = score + 5
console.log(score); // 15
score -= 3; // same as score = score - 3
score *= 2; // same as score = score * 2
console.log(score); // 24
Output:
15
24
Comparison Operators
console.log(5 > 3); // true
console.log(5 < 3); // false
console.log(5 >= 5); // true
console.log(5 == "5"); // true — loose equality allows type coercion
console.log(5 === "5"); // false — strict equality requires the same type
Output:
true
false
true
true
false
That last pair is important enough to deserve its own deep dive — see == vs === explained for why strict equality is almost always the safer choice.
Logical Operators
let age = 25;
let hasLicense = true;
console.log(age >= 18 && hasLicense); // true — AND: both must be true
console.log(age < 18 || hasLicense); // true — OR: at least one must be true
console.log(!hasLicense); // false — NOT: flips the boolean
Output:
true
true
false
&& and || don't just return true/false in JavaScript — they return one of the actual operand values, which is a handy trick you'll see used for default values and conditional logic once you get into writing functions.
