Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript Arithmetic Operators</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var x = 10, y = 5; document.writeln("Add : ", x + y); // Addition: 15 document.writeln("Sub : ", x - y); // Subtraction: 5 document.writeln("Mul : ", x * y); // Multiplication: 50 document.writeln("Div : ", x / y); // Division: 2 document.writeln("Mod : ", x % y); // Modulus: 0 document.writeln("-------Increment------"); document.writeln(x++); // x: 10, x become now 11 document.writeln(x); // x: 11 document.writeln(++x); // x become now 12, x: 12 document.writeln("-------Decrement------"); document.writeln(x--); // x: 12, x become now 11 document.writeln(x); // x: 11 document.writeln(--x); // x become now 10, x: 10 </script> </pre> </body> </html>
  Preview Arrow