The following operators are javascript Arithmetic operators.
- "+" Addition operator.
- "-" Subtraction operator.
- "*" Multiplication operator.
- "/" Division operator.
- "%" Modulus operator.
- "**" Exponential operator.
- "++" Increment operator.
- "--" Decrement operator.
In Arithmetic operation, the numbers are called Operands. The operands are literals, variables, or Expressions.
Example
<script type="text/javascript"> var a= 5+7; //operand are litrals. var b=10; var c=a+b; //operands are variables. var d=(30-5)/10; //operands are Expressions. </script>
Addition operators are used to performing addition operations or used to add numbers.
Example
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS Addition operation</h3> <p id="p1"></p> <script type="text/javascript"> var a= 75; var b=10; var c=a+b; document.getElementById("p1").innerHTML= "C="+c; </script> </body> </html>
JS Addition operation
The subtraction operator is used to subtract numbers.
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS subtraction operation</h3> <p id="p2"></p> <script type="text/javascript"> var d= 75; var e=10; var f=d-e; document.getElementById("p2").innerHTML= "f="+f; </script> </body> </html>
JS subtraction operation
3) Multiplication operation(*)
The multiplication operator is used to multiply numbers.
Example
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS Multiplication operation</h3> <p id="p3"></p> <script type="text/javascript"> var x= 75; var y=10; var z=x*y; document.getElementById("p3").innerHTML= "Z="+z; </script> </body> </html>
JS Multiplication operation
The division operator is used to divide numbers or used to find the quotient.
Example
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS Division operation</h3> <p id="p4"></p> <script type="text/javascript"> let p= 150; let q=3; let r=p/q; document.getElementById("p4").innerHTML= "r="+r; </script> </body> </html>
JS Division operation
The modulus operator is used to return remainders.
Example
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS Modulus operation</h3> <p id="p5"></p> <script type="text/javascript"> let m= 150%4; document.getElementById("p5").innerHTML= "remainder="+m; </script> </body> </html>
JS Modulus operation
6)Increment(++) and Decrement(--) operations
The increment operator is used for increment numbers and the decrement operator is used for decrement numbers.
Example
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h3>JS Inc/Dec operation</h3> <p id="p6"></p> <p id="p7"></p> <script type="text/javascript"> let i= 6; i++; //the value of i increase by 1 let d=10; d--; //the value of d decrease by 1 document.getElementById("p6").innerHTML= "i="+i; document.getElementById("p7").innerHTML= "d="+d; </script> </body> </html>
0 Comments