Arithmetic & Assignment in JavaScript

From the JavaScript cheat sheet · Operators · verified Jul 2026

Arithmetic & Assignment

Math and assignment operators

javascript
// Arithmetic
let x = 10 + 5; // 15
x = 10 - 5; // 5
x = 10 * 5; // 50
x = 10 / 5; // 2
x = 10 % 3; // 1 (remainder)
x = 2 ** 3; // 8 (exponentiation)

// Assignment operators
x += 5; // x = x + 5
x -= 5; // x = x - 5
x *= 5; // x = x * 5
x /= 5; // x = x / 5
x %= 3; // x = x % 3
x **= 2; // x = x ** 2

// Increment/Decrement
x++; // post-increment
++x; // pre-increment
x--; // post-decrement
--x; // pre-decrement
💡 + operator concatenates strings but performs addition with numbers
⚡ Pre-increment (++x) returns new value, post-increment (x++) returns old
📌 Use ** for exponentiation instead of Math.pow()
🔥 Assignment operators provide shorthand for common operations

Continue with JavaScript

Save the full cheat sheet or work through every related task.

More JavaScript tasks

Back to the full JavaScript cheat sheet