theory.js

Operators & Expressions

Arithmetic Operators

Arithmetic operators perform basic mathematical calculations in JavaScript.

  • + Addition (5 + 3 → 8)
  • - Subtraction (10 - 4 → 6)
  • * Multiplication (6 * 2 → 12)
  • / Division (9 / 3 → 3)
  • % Modulus (10 % 3 → 1) (Remainder of division)
  • ** Exponentiation (2 ** 3 → 8) (2 raised to the power of 3)
let a = 10, b = 2;
console.log(a + b); // 12
console.log(a - b); // 8
console.log(a * b); // 20
console.log(a / b); // 5
console.log(a % b); // 0
console.log(a ** b); // 100