JavaScript Arithmetic Operators

๐Ÿ“˜ What are Arithmetic Operators?

Arithmetic operators are used to perform mathematical calculations on numbers in JavaScript, such as addition, subtraction, multiplication, and division.

โž— JavaScript Arithmetic Operators

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulus (remainder)
  • ++ Increment
  • -- Decrement

๐Ÿ’ป Basic Examples

let a = 10;
let b = 3;

console.log(a + b); // 13
console.log(a - b); // 7
console.log(a * b); // 30
console.log(a / b); // 3.33
console.log(a % b); // 1
            

โž• Increment & โž– Decrement

let count = 5;

count++; // 6
count--; // 5
            
โš ๏ธ Increment and decrement change the value by 1.

๐Ÿงช Try It Yourself

Click the button to calculate using arithmetic operators: