Arithmetic Operators in JavaScript
Numeric Operators.
JavaScript’s arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/) .
In addition, JavaScript provides modules(%), increment(++), decrement(- -) and unary negation(-) operators.
1. Adding ( + )
The addition operator (+) adds numbers . The +
operator also serves as string concatenation if you use strings, so pay attention. addition operator performs concatenation operation when one of the operands is of string type
2. Subtracting (-)
The subtraction operator (-) subtracts numbers.
3. Multiplying (*)
The multiplication operator (*) multiplies numbers. The remainder is a very useful calculation in many use cases.A reminder by zero is always NaN(Not a Number)
4. Dividing ( / )
The division operator (/
) divides numbers.
5.Remainder (%)
The modulus operator (%) returns the division remainder numbers.
6. Incrementing ( ++ )
The increment operator ( ++ ) increments numbers. Increment a number. This is a unary operator, and if put before the number, it returns the value incremented.
7. decrement (- -)
The decrement operator (- -) decrements numbers.
8.Exponentiation ( ** )
The exponentiation operator (**
) raises the first operand to the power of the second operand.
9. Adding ( + )
The + operator also does string concatenation .
10. If you add a string to a number (or other value) everything is converted into a string first