Lesson 7 / 38
Operators
Arithmetic, comparison, logical, and modern nullish operators.
Arithmetic & comparison
Standard math operators plus ** for exponents, and six comparison operators.
console.log(2 ** 10); // 1024
console.log(10 % 3); // 1
console.log(5 > 3 && 2 < 4); // trueLogical short-circuiting
&& and || return one of their operands, not just true/false — used to pick fallback values.
const name = "" || "Guest"; // "Guest"
const user = { age: 0 };
const age = user.age ?? 18; // 0, not 18!?? vs ||
?? (nullish coalescing) only falls back on null/undefined; || also falls back on 0, "", false — a common bug source.