But since it is also loosely typed, a variable can have it's type changed after it has been declared.
The six primitive types are:
Take the following code sample:
var x = "Hello world"; //String var x = 50; //Number var x = true; //Boolean
In this example a variable
x has been declared three times with three
different values. Crucially however, the values all differ in type. The first
value is a string and therefore the String type is assigned, the second value is a numeric value and
therefore the Number type is assigned and the thrid value is a boolean value (
false) and therefore has the Boolean type assigned to it.
Despite the difference in types, it is possible to assign a value of a different type to the same variable because the language is loosely typed.
Null is a special type that means that the value of the variable is actually
it can be assigned just like a normal value:
var x = null; //Null
var x = undefined; //Undefined
There is more on the undefined value on Wikipedia.