Menu Close

JavaScript Arithmetic Operators

In this article, you will learn JavaScript arithmetic operators with the help of examples. In the previous tutorial, we have seen all about JavaScript operators and their types.

Before start this article, let’s know little bit about operator.

What is operator ?

Operator is special type of symbol that is used to perform calculate on values and variables.

JavaScript Arithmetic Operators

JavaScript arithmetic operators are used to perform arithmetic operations. There are various types of operation available in arithmetic operators.

JavaScript Arithmetic Operators

OperatorNameExample
+Additionx + y
Subtractionx – y
*Multiplicationx * y
/Divisionx / y
%Remainderx % y
++Incrementx ++, ++x
Decrementx –, –x
**Exponentiationx ** y

Arithmetic Operation

Arithmetic operation operates on two numbers and those two numbers can be literals and variables.

Operators and Operands

The numbers are called operands and operation is defined by operator.

Let’s take simple example to understand operands and operator.

Example:

100 + 20 

In above table 100 and 20 are operands, + is the operator.

Addition

The addition operator ( + ) is used to add numbers.

var result = 100 + 50;
console.log(result)

Subtraction

The Subtraction operator ( – ) is used to subtract one number from other numbers.

var result = 100 - 50;
console.log(result)

Multiplication

The Multiplication operator ( * ) is sued to multiply one or more values.

var result = 100 * 50;
console.log(result)

Dividing

The Dividing operator ( / ) is used to divide the numbers.

var result = 100 / 50;
console.log(result)

Remainder

The modulus operator ( % ) is used to return the division remainder.

var result = 109 / 50;
console.log(result)

Incrementing

Increment operator ( ++ ) is used to increment the numbers.

var x = 10;
x++
console.log(x)

Decrement

Decrement operator ( – – ) is used to decrement the numbers.

var x = 10;
x--
console.log(x)

Exponentiation

The exponentiation operator (**) raises the first operand to the power of the second operand.

var x = 10;
console.log(x ** 2);

Conclusion

In this tutorial, you have learned all about JavaScript arithmetic operators with the help of examples.
Arithmetic operators are always used to perform arithmetic operations on operands. Operands can be values and variables.

If you like this article, please share and keep visit for further JavaScript interesting tutorials.

Reference:- Click Here

JavaScript Operators
JavaScript Comparison Operators

Related Posts