Arithmetic Operators
Arithmetic operators are needed to perform operations on different types of data. There are 2 basic types of arithmetic operators:
- Binary operators require two operands, such as
x + yora * b - Unary operators require only one operand, such as
-xor+x
Binary arithmetic operators
- Addition
+ - Subtraction
- - Multiplication
* - Division
/ - Remainder
% - Exponentiation
**
Unary arithmetic operators
- The unary plus operator indicates a positive value. It's an optional operator if you only work with numbers
- e.g.
console.log(+7)
- e.g.
- The unary minus operator makes a value or an expression negative
- e.g.
console.log(-(100 + 5))
- e.g.