The JavaScript Arithmetic Operators include operators like Addition, Subtraction, Multiplication, Division, and Modulus. All these operators are binary operators, which means they operate on two operands.
JavaScript Arithmetic Operators list
The below table shows the Arithmetic Operators with examples.
| Arithmetic Operators | Operation | Example |
|---|---|---|
| + | Addition | 10 + 2 = 12 |
| – | Subtraction | 10 – 2 = 8 |
| * | Multiplication | 10 * 2 = 20 |
| / | Division | 10 / 2 = 5 |
| % | Modulus – It returns the remainder after the division | 10 % 2 = 0 (Here remainder is zero). If it is 10 % 3 then it will be 1. |
JavaScript Arithmetic Operators Example
For this Arithmetic Operators example, We are using two variables a and b, and their values are 12 and 3. We are going to use these two variables to perform various arithmetic operations.
let a = 12, b = 3;
let addition, subtraction, multiplication, division, modulus;
addition = a + b; //addition of 3 and 12
subtraction = a - b; //subtract 3 from 12
multiplication = a * b; //Multiplying both
division = a / b; //dividing 12 by 3 (number of times)
modulus = a % b; //calculation the remainder
console.log('Addition of ' + a + ' and ' + b + ' is = ' + addition);
console.log('Subtraction of ' + a + ' and ' + b + ' is = ' + subtraction);
console.log('Multiplication of ' + a + ' and ' + b + ' is = ' + multiplication);
console.log('Division of ' + a + ' and ' + b + ' is = ' + division);
console.log('Modulus of ' + a + ' and ' + b + ' is = ' + modulus);
Performing Arithmetic Operations
Addition of 12 and 3 is = 15
Subtraction of 12 and 3 is = 9
Multiplication of 12 and 3 is = 36
Division of 12 and 3 is = 4
Modulus of 12 and 3 is = 0
Arithmetic Operators program Example 2
For this JavaScript example, we are using two variables, a and b, and their values are 12 and 3. Here, we are going to use these variables to show you how to display the Arithmetic operations output in Paragraphs. Similar to arithmetic operators, we can use the assignment operators to perform mathematical calculations.
<!DOCTYPE html>
<html>
<head>
<title>JavascriptArithmeticOperators 2</title>
</head>
<body>
<h1>Performing Arithmetic Operations </h1>
<p id = 'add'> Addition </p>
<p id = 'sub'> Subtraction </p>
<p id = 'mul'> Multiplication </p>
<p id = 'div'> Division </p>
<p id = 'mod'> Modulus </p>
<script>
let a = 12, b = 3;
let add, sub, mul, div, mod;
add = a+b; //addition of 3 and 12
sub = a-b; //subtract 3 from 12
mul = a*b; //Multiplying both
div = a/b; //dividing 12 by 3 (number of times)
mod = a%b; //calculation the remainder
document.getElementById("add").innerHTML = "Addition of " +a +' and ' +b +" is = " + add;
document.getElementById("sub").innerHTML = "Subtraction of " +a +' and ' +b +" is = " + sub;
document.getElementById("mul").innerHTML = "Multiplication of " +a +' and ' +b +" is = "+ mul;
document.getElementById("div").innerHTML = "Division of " +a +' and ' +b +" is = " + div;
document.getElementById("mod").innerHTML = "Modulus of " +a +' and ' +b +" is = " + mod;
</script>
</body>
</html>

If there is any situation to replace the Increment or Decrement operator, we can use the arithmetic operator to get the same result. For example,
- x++ is equivalent to x = x + 1
- x– is equivalent to x = x – 1