Joydip Panchal Javascript Tutorial
How to declare a variable in javascript??

You can declare any type of variables with the var statement.

Example :

<html>
<body>

<script type='text/javascript'>

var x=34.5;
document.write(x + "<br>"

var x=34;
document.write(x + "<br>"

var x="Help2engg";
document.write(x + "<br>"

var x='h';
document.write(x + "<br>"
</script>

</body>
</html>

Here, you notice that same name can be used for storing different types of data like float,integer,string and char..
Like · Comment ·
Kaushal Mejadiya and Arpan Patel like this
Download Android App