- To be able to use input and output statements.
- To be able to use arithmetic operators.
- It was designed to add interactivity to HTML pages
- It is an interpreted language (means that scripts execute without preliminary compilation)
- Create special effects with images that give the impression of a button.
- Validate information that users enter into your web forms.
- Open pages in new windows, and customise the appearance of those new windows.
- Detect the capabilities of the user’s browser and alter your page’s content appropriately.
- Create custom pages “on the fly” without the need for a server-side language like PHP.
var a = 12;
var b = 34;
document.write("Value of a = " + a + " and b = "+ b);
result = a + b;
document.write("<br>Addition of a & b = " + result );
result = a - b;
document.write("<br>Subtraction of a & b = " + result );
result = a * b;
document.write("<br>Multiplication of a & b = " + result );
result = a / b;
document.write("<br>Division of a & b = " + result );