Variables in JavaScript

It is the most important topic because of all the JavaScript application included variables and other, so it is very necessary to know all about variable like how to declare the variable and how to assign value to these variables.

How to declare :

Var name;

How to assign value to the variable:

Var name=”naveen”;

Example:

Here we discuss simple example to understand the working of variables.

html>

<head>

<title>Variables</title>

<script type="text/javascript">

var one = 5;

var two = 3;

var add = one + two;

            document.write("First No: = " + one + "<br />Second No: = " + two + " <br />");

            document.write(one + " + " + two + " = " + add + "<br/>");

</script>

</head>

<body>

</body>

</html>

Result:

               First No: = 5
               Second No: = 3 
                5 + 3 = 8

Powered  by Codersarts