**Arithmetic operators in JavaScript**

**What are arithmetic operators in JavaScript?**

Arithmetic operator in JavaScript are the mathematical symbols used to perform certain operations such as addition, subtraction, multiplication and many more related and similar to it. Unlike normal arithmetic operations in mathematics, programming languages use some additional set of operations.

Following is the list of Arithmetic operations used in JavaScript programming language.

- + (use for addition between numbers)
- – (Use to subtract two numbers)
- / (Use to divide two numbers)
- *(Use to multiply two numbers)
- ++ (Increment by 1)
- — (Decrement by 1)

Arithmetic operator in JavaScript increment operator and decrement operators are discussed here.

**Arithmetic Operation Addition**

Arithmetic operation Addition is used to add two numbers. Keep this thing in mind that we can not add two strings using this operator but we can add only numbers with the help of this operator. To add the two string actually means concatenating the two strings so the function concat is used to attach two strings. We will deal with the strings concatenation later.

To successfully perform the arithmetic operations in JavaScript operators of addition, the two numbers must be either integers or either double value. (Double in JavaScript means floating number or in easy words number with the decimal point).

Code:

let x=2

let y=3

z=x+y

console.log(z)

Output

5

Arithmetic operation adds the number one by one.

**Arithmetic Operation Subtraction**

Arithmetic operation subtraction is used in the same way and procedure the arithmetic operation addition is performed. Arithmetic operator in Javascript The only point where it gets the difference is the calculation result. Subtraction actually deducts the value on right side from the value placed on left side. This is very simple and easy process. They way you can’t add the strings, similarly you can’t subtract the strings.

This is because strings mainly consist of characters. Set of character collectively known as the string. In easy words if the value is placed between double codes(””) then it becomes string. For example x=”12”.

Here, x is not a number or integer rather it is behaving as string here so you can’t add the x with a number. You will encounter an error.

Code:

let x=5

let y=3

z=x-y

console.log(z)

Output

2

**Arithmetic Operation Multiplication**

Arithmetic operation Multiplication, as it wold be quite clearly understood by the keyword multiplication, arithmetic operators or operator in JavaScript of multiplication are used to multiply two numbers. Again, for more clear and precise concept you can not even multiply the strings. This is actually not a loop hole in programming languages rather no programming language allows you to multiply any two strings. You can just concatenate two strings.

Code:

let x=2

let y=3

z=x*y

console.log(z)

Output

6

Division Arithmetic operator

Division Arithmetic operator

Division arithmetic operator in JavaScript is used to divide the two numbers either integers or a float or double (decimal) number but it must not be a string otherwise you will encounter an error because it is not applicable over the strings.

Code:let x=8

let y=2

z=x/y

console.log(z)

Output

4