Varible types in javascript

There is only one type of variable in JavaScript i.e. "Var".

We can use Var as any type, means we can declare Var as integer, Var as Float, Var as String, Var as Array or even Var as a Control.

The Below Examples will illustrate how we can define Var.

Var i=0;

Here i will work as Integer, what ever operations we can perform on int we can perform on i now.

Var f=1.23;
Here f will work as Float

Var ary=new Array(); or
Var ary=new Array(24,5,2,3);

Here ary will work as Array, you can find the length of the array by using ary.length and can access the variables by it's index in the above example ary[1] will return "24" and ary[2] will return "5" and soon...

var txt=document.getElementById("cntrlid");

Here txt will work as TextBox and you can perform all the operations that textbox support on "txt"

Var ddl=document.getElementById("dropdownid");

Here ddl will work as Dropdown list, and how to add items to dropdown, and get value from dropdown we will see in our next articles.

So "Var" is the variable that will work as many types based on the value that we have assigned.