JavaScript Operator Reference
Complete reference guide for all JavaScript operators
📚 JavaScript Operator Reference
This comprehensive reference covers all JavaScript operators organized by category. Use this as a quick lookup guide for syntax and examples.
// Quick operator examples
let a = 10, b = 5;
console.log(a + b); // Arithmetic: 15
console.log(a > b); // Comparison: true
console.log(a && b); // Logical: 5
Output:
15
true
5
true
5
Operator Categories
Arithmetic
Mathematical operations
+ - * / % ** ++ --
Assignment
Assign values to variables
= += -= *= /= %=
Comparison
Compare values
== === != !== > < >= <=
Logical
Boolean operations
&& || ! ?? ?.
🔹 Arithmetic Operators Reference
| Operator | Name | Example | Result |
|---|---|---|---|
+
|
Addition |
5 + 3
|
8 |
-
|
Subtraction |
5 - 3
|
2 |
*
|
Multiplication |
5 * 3
|
15 |
/
|
Division |
15 / 3
|
5 |
%
|
Modulus |
7 % 3
|
1 |
**
|
Exponentiation |
2 ** 3
|
8 |
🔹 Comparison Operators Reference
| Operator | Name | Example | Result |
|---|---|---|---|
==
|
Equal to |
5 == "5"
|
true |
===
|
Strict equal |
5 === "5"
|
false |
!=
|
Not equal |
5 != 3
|
true |
!==
|
Strict not equal |
5 !== "5"
|
true |
>
|
Greater than |
5 > 3
|
true |
>=
|
Greater or equal |
5 >= 5
|
true |
🔹 Quick Reference Examples
Common operator combinations and patterns:
// Assignment with operation
let x = 10;
x += 5; // x = x + 5 = 15
x *= 2; // x = x * 2 = 30
x %= 7; // x = x % 7 = 2
// Logical short-circuit
let name = user.name || "Anonymous";
let data = cache?.data ?? fetchData();
// Comparison chains
let age = 25;
let category = age < 13 ? "child" :
age < 20 ? "teen" :
age < 60 ? "adult" : "senior";
// Bitwise flags
const READ = 1; // 001
const WRITE = 2; // 010
const EXECUTE = 4; // 100
let permissions = READ | WRITE; // 011
let canRead = permissions & READ; // true
console.log(x, name, category, canRead);
Output:
2 "Anonymous" "adult" 1