Following
table summarizes Arithmetic operators supported by Javascript.
 
Operator 
 | 
  
Description 
 | 
 
+ 
 | 
  
Additon
  (also used for String concatenation) 
 | 
 
- 
 | 
  
Subtraction 
 | 
 
/ 
 | 
  
Division 
 | 
 
* 
 | 
  
Multiplication 
 | 
 
% 
 | 
  
Gives
  Remainder 
 | 
 
arithmetic.html
<!DOCTYPE html> <html> <head> <title>Arithmetic Operators</title> <style> p{ font-size: 2em; color: seagreen; } </style> </head> <body> <p> <script type="text/javascript"> var a = 23; var b = 3; document.write("a = " + a + "<br />"); document.write("b = " + b + "<br />"); document.write("a+b = " + (a+b) + "<br />"); document.write("a-b = " + (a-b) + "<br />"); document.write("a*b = " + (a*b) + "<br />"); document.write("a/b = " + (a/b) + "<br />"); document.write("a%b = " + (a%b) + "<br />"); </script> </p> </body> </html>
Note
Unlike
languages like Java, integer division in JavaScript returns float value.
No comments:
Post a Comment