There are many types of JavaScript variables.
When you assign a text value to a variable, enclose the value in double or single quotation marks.
Do not use quotation marks when the value you assign to a variable is numeric. If you enclose a value in quotation marks, the value is treated as text.
JavaScript is sensitive to capitalization.
JavaScript does not use a value to declare a variable whose value is actually undefined.
After the following statement has been executed, the value of the variable carname will be undefined:
var carname;
If you re-declare a JavaScript variable, the value of the variable is not lost:
After the following two statements are executed, the value of the variable carname remains "Volvo":
var carname= "Volvo";
var carname;
JavaScript Boolean (logic) can have only two values: TRUE or FALSE.
The following code creates an array named cars:
var cars=new Array ();
Cars[0]= "Audi";
Cars[1]= "BMW";
Cars[2]= "Volvo";
or (condensed array):
var cars=new Array ("Audi", "BMW", "Volvo");
or (literal array):
var cars=["Audi", "BMW", "Volvo";
JavaScript objects
Objects are separated by curly braces. Inside the parentheses, the properties of the object are defined in the form of name and value pairs (name:value). Attributes are separated by commas:
var person={firstname: "Bill", LastName: "Gates", id:5566};
The object (person) in the example above has three attributes: FirstName, LastName, and ID.
Object properties are addressed in two ways:
name=person.lastname;name=person["LastName"];
Undefined and Null
Undefined This value indicates that the variable does not contain a value.
You can empty a variable by setting the value of the variable to null.
Basic JavaScript knowledge