HTML CSS JavaScript SEO Python Posts Privacy About Contact

JS Arithmetic

JavaScript arithmetic operators are used to perform arithmetic on numbers.

JavaScript arithmetic operators are used to perform arithmetic on numbers (literals or variables).

Arithmetic Operators

A typical arithmetic operation operates on two numbers. The two numbers can be literals, variables, or expressions.

OperatorDescription
+Addition
-Subtraction
*Multiplication
**Exponentiation (ES2016)
/Division
%Modulus (Division Remainder)
++Increment
--Decrement

Addition and Subtraction

The addition operator (+) adds numbers together. The subtraction operator (-) subtracts numbers.

Preview

Multiplication and Division

The multiplication operator (*) multiplies numbers. The division operator (/) divides numbers.

Preview

Operator Precedence

Operator precedence describes the order in which operations are performed in an arithmetic expression. Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).

As in traditional school mathematics, the precedence can be changed by using parentheses.

Preview