Arithmetic
Master this topic with zero to advance depth.
Expert Answer & Key Takeaways
Mastering Arithmetic is essential for high-fidelity technical architecture and senior engineering roles in 2026.
JavaScript Arithmetic
Arithmetic operators perform arithmetic on numbers (literals or variables). Standard mathematical order (PEMDAS/BODMAS) applies to these calculations.
1. Basic Operators
| Operator | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
** | Exponentiation (ES2016) |
/ | Division |
% | Modulus (Division Remainder) |
++ | Increment |
-- | Decrement |
2. Modulus (Remainder)
The modulus operator (
%) returns the division remainder.let x = 5;
let y = 2;
let z = x % y; // z will be 13. Exponentiation
The exponentiation operator (
**) raises the first operand to the power of the second operand.let x = 5;
let z = x ** 2; // z will be 254. Increment and Decrement
The increment operator (
++) increments numbers. The decrement operator (--) decrements numbers.let x = 5;
x++;
let z = x; // z is 6
let y = 5;
y--;
let w = y; // w is 45. Operator Precedence
Operator precedence describes the order in which operations are performed in an arithmetic expression.
let x = 100 + 50 * 3;
// Multiplication has higher precedence, so it is (50 * 3) + 100 = 250When using parentheses, the operations inside the parentheses are computed first:
let x = (100 + 50) * 3; // (150) * 3 = 450Always use parentheses when you want to be sure of the calculation order. It also makes the code easier to read for other developers.
Top Interview Questions
?Interview Question
Q:What does the modulus (%) operator do?
A:
The modulus operator returns the remainder after a division. For example, 10 % 3 results in 1 because 3 goes into 10 three times with 1 left over.
?Interview Question
Q:How do you calculate 2 to the power of 3 in modern JS?
A:
You can use the exponentiation operator (**): 2 ** 3. Alternatively, you can use Math.pow(2, 3).
?Interview Question
Q:Which arithmetic operation has higher precedence: Addition or Multiplication?
A:
Multiplication has higher precedence than addition. In the expression 5 + 2 * 3, the multiplication (2 * 3) happens first.
Course4All Engineering Team
Verified ExpertSenior Full-Stack Engineers & V8 Experts
Our JavaScript and engine-level content is developed by a collective of senior engineers focused on high-performance web architecture and 2026 standards.
Pattern: 2026 Ready
Updated: Weekly
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.