Arithmetic
Perform mathematical operations like addition, subtraction, etc.
Operators are symbols used to perform operations on values (operands).
An expression is a combination of values, variables, and operators that produces a result.
let result = 10 + 5;+ → operator10, 5 → operands10 + 5 → expressionArithmetic
Perform mathematical operations like addition, subtraction, etc.
Assignment
Assign values to variables.
Comparison
Compare values and return boolean results.
Logical
Combine multiple conditions.
Addition (+)
Adds two values
Example: 10 + 5 = 15
Subtraction (-)
Example: 10 - 5 = 5
Multiplication (*)
Example: 10 * 5 = 50
Division (/)
Example: 10 / 5 = 2
Modulus (%)
Returns remainder
Example: 10 % 3 = 1
Exponentiation ()**
Example: 2 ** 3 = 8
let a = 10;let b = 3;
console.log(a + b); // 13console.log(a % b); // 1Used to assign values.
let x = 10;x += 5; // x = x + 5x -= 2;x *= 3;x /= 2;Return true or false.
10 > 5; // true10 < 5; // false10 >= 10; // true10 <= 5; // false10 == "10"; // true (type coercion)10 === "10"; // false (strict)"5" + 2; // "52""5" - 2; // 3Used to combine conditions.
AND (&&) True if both conditions are true
OR (||) True if at least one condition is true
NOT (!) Reverses boolean value
let age = 20;
console.log(age > 18 && age < 30); // trueconsole.log(age > 18 || age < 10); // trueconsole.log(!(age > 18)); // falseJavaScript stops evaluation early.
true || console.log("Won't run");false && console.log("Won't run");Operate on a single operand.
let x = 5;
x++; // incrementx--; // decrementtypeof x; // type checkDetermines execution order.
let result = 10 + 5 * 2; // 20, not 30