JavaScript

This page gently explains JavaScript arithmetic operators with small examples for addition, subtraction, multiplication, division, remainders, and powers.

Goal: understand the basic arithmetic operators and notice when strings and numbers behave differently.

Arithmetic operators

OperatorMeaningExample
+Add, or join strings5 + 3 // 8
-Subtract, or change a sign5 - 3 // 2
*Multiply5 * 3 // 15
/Divide8 / 2 // 4
%Remainder12 % 5 // 2
**Power2 ** 3 // 8

Small examples

JavaScript

const total = 5 + 3;
const remainder = 12 % 5;
const square = 4 ** 2;

console.log(total);      // 8
console.log(remainder);  // 2
console.log(square);     // 16

When + joins text

If either side of + is a string, JavaScript joins the values as text. Convert input explicitly when you mean to calculate with numbers.

JavaScript

"5" + 3           // "53"
Number("5") + 3    // 8

Common cautions

Related topics