October 7, 1999 - Object Types
October 7, 1999|
Tips: October 1999
Yehuda Shiran, Ph.D.
Math, that you cannot modify.
PI, for example, is a property of the
Mathobject and obviously cannot be modified. User-defined objects are created by the author. The
courseobject discussed on October 6, 1999, is a user-defined object.
An object can be a property of another object, thus creating an object hierarchy. Suppose an object
a has two object properties,
c. The object
b has two properties,
e, while the object
c has four properties,
i. Let's assume that
10. The following expressions are references to various properies in this object hierarchy:
alert(a.b.d) // prints 16 alert(a.b.e) // prints 42 alert(a.c.f) // prints true alert(a.c.g) // prints king alert(a.c.h) // prints 13 alert(a.c.i) // prints 10
A property belongs to an object, and only to one object. A variable may be named exactly like a property of an object. The following statement is valid:
d = a.b.d;
However, a variable cannot have the same name as an object at the same level (scope). The following statement is not valid:
a = a.b.d;
It's good practice to avoid repeating names.