+
Adds numbers or concatenates strings. Convert input before using it in totals.
Arithmetic operators calculate values, but the plus operator also joins strings. That double role is powerful and dangerous.
const quantity = 5; const price = 12; quantity * price; // 60 "5" + price; // "512"
Operators & Expressions
Arithmetic operators work with numbers and BigInts. You will use them for totals, counters, percentages, dimensions, indexes, timers and calculations inside UI logic.
The common operators are addition, subtraction, multiplication, division, remainder and exponentiation. Increment and decrement also exist, but they mutate a variable as part of the expression.
The dangerous detail is +. With numbers, it adds. With strings, it concatenates. If one side is a string, JavaScript can move the whole expression toward text instead of math.
Adds numbers or concatenates strings. Convert input before using it in totals.
Numeric operators that usually push values toward numbers.
Remainder after division. Useful for cycles, even checks and wrapping indexes.
Exponentiation. Use it for powers, not repeated multiplication by hand.
Examples
const rawItems = "5"; const itemCount = Number(rawItems); const pricePerItem = 12; const total = itemCount * pricePerItem; console.log(total); // 60
const rawItems = "5"; const pricePerItem = 12; const total = rawItems + pricePerItem; console.log(total); // "512"
Rules that matter
JavaScript operators are compact, but compact is not always clear. Convert values before comparing or calculating, use strict checks by default and add parentheses when a future reader would otherwise need to remember a precedence table.
Input values are strings. Convert them before math.
+ is both addition and string concatenation.
Invalid numeric conversion produces NaN and can poison the rest of a calculation.
count += 1 is clear. Complex ++ expressions are harder to read.
Remainder is useful for even checks and rotating through indexes.
BigInt arithmetic must stay BigInt unless you convert deliberately.
Production thinking
Arithmetic bugs often do not crash the page. They quietly show the wrong total, wrong index or wrong state.
Bad calculations can produce wrong validation text, wrong progress values and wrong disabled states.
Production code should normalize numeric input at boundaries and keep calculation expressions small enough to read.
If prices, counts or ratings are calculated in JavaScript, wrong arithmetic can display wrong content and structured values.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Say the answer in plain language. If you can explain the operator behavior, you can debug the expression.