Take a look at the following code:
//from basicObject.html //create the critter var critter = new Object(); //add some properties critter.name = "Milo"; critter.age = 5; //view property values alert("the critter's name is " + critter.name);
The way it works is not difficult to follow:
Create a new Object.
Add properties to the object.
A property is a subvariable. It’s nothing more than a variable attached to a specific object. When you assign a value to critter.name, for example, you’re specifying that critter has a property called name and you’re also giving it a starting value.
An object can have any number of properties.
Just keep adding properties. This allows you to group a number of variables into one larger object.
Each property can contain any type of data.
Unlike arrays where it’s common for all the elements to contain exactly the same type of data, each property can have a different type.
Use the dot syntax to view or change a property.
If the critter object has a name property, you can use critter.name as a variable. Like other variables, you can change the value by assigning a new value to critter.name or you can read the content of the property.