JavaScript Arithmetic Operators - Java Operators with Example
JavaScript Arithmetic Operators
- Arithmetic operators perform arithmetic on numbers (literals or variables).
Operator | Description |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
** | Exponentiation (ES2016) |
/ | Division |
% | Modulus (Remainder) |
++ | Increment |
-- | Decrement |
Arithmetic Operations
- A typical arithmetic operation operates on two numbers.
- The two numbers can be literals.
Sample Code
Output
Operators and Operands
- The numbers (in an arithmetic operation) are called operands.
- The operation (to be performed between the two operands) is defined by an operator.
Operand | Operator | Operand |
---|---|---|
100 | + | 50 |
Adding
- The addition operator (+) adds numbers:
Sample Code
Output
Subtracting
- The subtraction operator (-) subtracts numbers.
Sample Code
Output
Multiplying
- The multiplication operator (*) multiplies numbers.
Sample Code
Output
Dividing
- The division operator (/) divides numbers.
Sample Code
Output
Remainder
- The modulus operator (%) returns the division remainder.
Sample Code
Output
Incrementing
- The increment operator (++) increments numbers.
Sample Code
Output
Decrementing
- The decrement operator (--) decrements numbers.
Sample Code
Output
Exponentiation
- The exponentiation operator (**) raises the first operand to the power of the second operand.
Sample Code
Output
Operator Precedence
- Operator precedence describes the order in which operations are performed in an arithmetic expression.