Data Types (types of information) are used to determine the type of data values to variables. To match the reference data variables to use are as follows.
-number refers to the figure contains an integer data type (Integer) and a real number (Floating).
for example,
var x=34.50;
var y=34;
Example:
<html>
<body>
<script>
var x=34.50;
var y=34;
document.write(x + "<br>")
document.write(y + "<br>")
</script>
</body>
</html>
This is the result:
-boolean or logical data refers to the two logical states which is true (True) and false (False).
for example,
var x = true;
var y = false;
-string refers to text data. Which will be defined in quotation marks ("...").
for example,
var name = "Harry Potter";
var age = "age 23 years";
Example:
<html>
<body>
<script>
var name1="Batman";
var name2="Superman";
var name3="Spiderman";
document.write(name1 + "<br>")
document.write(name2 + "<br>")
document.write(name3 + "<br>")
</script>
</body>
</html>
This is the result:
-null means no data values for any null-terminated value of the variable storage space out of memory.
for example,
cars = null;
person = null;
-Array is multiple data comes sequentially.
for example,
var cars = new Array ();
cars [0] = "Toyota";
cars [1] = "Honda";
cars [2] = "BMW";
Example:
<html>
<body>
<script>
var i;
var cars = new Array();
cars[0] = "Toyota";
cars[1] = "Honda";
cars[2] = "BMW";
for (i=0;i<cars.length;i++)
{
document.write(cars[i] + "<br>");
}
</script>
</body>
</html>
This is the result:
Next