How to Use of Arithmetic Operator in JavaScript

In this article I have described about the Arithmetic operator used in JavaScript
  • 1788

JavaScript Operator - Arithmetic Operator

  • An operator is used to transform one or more value into a single resultant variable.
  • The value to which the operator is applied is referred as operands.
  • A combination of an operator and its operand referred as an Expression.


  • for some operator such as multiplication (*) the order of the operand do not matter. for example A*Y=Y*A true for all integer and floating point number.
  • Other operator like String concatenation (+), the order of operand matter. for example- "ab" +"cd" not same as  "cd" +"ab".

lets take an example

<html xmlns="">
<title>JavaScript Oerator</title>

<p>JavaSript + operator example with variable</p>
<button onclick="myFunction()">CLICK</button>
<p id="demo"></p>
<script type="text/javascript">
function myFunction() 
txt1 = "welcome to";
txt2 = " MCN IT SOLUTION ";
txt3 = txt1 + txt2;
document.getElementById("demo").innerHTML = txt3;


when we run above program



Arithmetic Operator

The table having some Arithmetic operator


    Operator          Description                       Example
+ add two operand x=y+2
- subtract second operand from first one x=y-2
* multiply both operand x=y*2
/ divide numerator by denumerator x=y/2
% modulus operator x=y%2
++ Increment Operator x=++y  x=y++
-- Decrement Operator x=--y  x=y--

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2018 DotNetHeaven. All rights reserved.