JS Arithmetic
JS Arithmetic
Arithmetic
Operators
JS Arithmetic
Arithmetic Operators- perform
arithmetic on numbers(literals
or variable).
Operator and
Operator
+
Operand
Description
Addition
- Subtraction
* Multiplication
** Exponentiation
/ Division
%
++ Modulus(Remainder)
increment
Decre ment
Arithmetic Operations
A typical arithmetic operation
operates on two numbers.
Example:
The two
numbers let x = 100 +
50;
can be literals:
Example:
or let x = a +
b;
variable:
Example:
Example:
let x = (100 + 50) *
3;
Precedenc
e
When many operations have the same
precedence (like addition and
subtraction or multiplication and
division), they are computed from left
to
right.
Operator Precedence
Example:
let x = 100 + 50 - 3;
Example:
let x = 100 / 50 *
3;