Arithmetic Operators
Arithmetic Operators
Section titled “Arithmetic Operators”Introduction
Section titled “Introduction”Arithmetic operators perform mathematical calculations on numeric values.
Visual Explanation
Section titled “Visual Explanation”flowchart LR A["5 + 3 = 8"] --> Add[Addition] B["5 - 3 = 2"] --> Sub[Subtraction] C["5 * 3 = 15"] --> Mul[Multiplication] D["6 / 3 = 2"] --> Div[Division] E["5 % 2 = 1"] --> Mod[Modulus] F["2 ** 3 = 8"] --> Exp[Exponentiation]Operators
Section titled “Operators”let a = 10, b = 3;
a + b; // 13 — additiona - b; // 7 — subtractiona * b; // 30 — multiplicationa / b; // 3.3333 — divisiona % b; // 1 — modulus (remainder)a ** b; // 1000 — exponentiation (ES7)Increment & Decrement
Section titled “Increment & Decrement”let count = 5;
count++; // 5 (post-increment) → count = 6++count; // 7 (pre-increment)count--; // 7 (post-decrement) → count = 6--count; // 5 (pre-decrement)Operator Precedence
Section titled “Operator Precedence”2 + 3 * 4; // 14 — multiplication first(2 + 3) * 4; // 20 — parentheses overrideSummary
Section titled “Summary”- Arithmetic operators work with numbers
+also concatenates strings%gives remainder**is for exponentiation (ES7)