An object is a data type that contains named pieces of data. Each named datum is called a property. Each property has a name, and the object associates a value with each property name. A property value may be of any type. In effect, the properties of an object are variables within the "name space" created by the object.
You normally use the . operator to access the value of an object's properties. The value on the left of the . should be a reference to an object (usually just the name of the variable that contains the object reference). The value on the right of the . should be the name of the property. This must be an identifier, not a string or an expression. For example, you refer to the property p in object o with o.p. Or, you refer to the property document in the object parent with parent.document. The . operator is used for both reading and writing object properties. For example:
// Read a property value: w = image.width; // Set a property value: window.location = "http://my.isp.com/my_home_page/index.html"; // Read one property and set it in another property image.src = parent.frames.location
You can add a new property to an object simply by setting its value. Thus, you might add a property to the object win with code like the following:
win.creator = self;
Once a property has been defined in an object, however, there is no way to undefine it. You may set the value of a property to the special undefined value, by assigning the value of an undefined property, but this just changes the value of the property without actually undefining it. You can demonstrate that the property still exists by using a for/in loop to print out the name of all defined properties:
for (prop in obj) property_list += prop + "\n"; alert(property_list);