|Lesson 15: Object|
Think of properties as variables and methods as functions for the least confusion.
1) Accessing Object Properties and Methods
A) . operator
When using the . operator, you are restricted to using an object on the left and a property or method name on the right. You must use the literal property/method name, no dynamically generated strings can be used with the . operator! Example:
good = document.location
bad = document."location"
B)  operator
When using the  operator, you are not limited to only a literal property name in the brackets, but can use either strings enclosed in quotes (associative arrays) or numerical values depending upon the referenced values held by the object on the left, allowing access to dynamically generated objects and their properties and or methods. Examples:
[Note- n can be an integer or an expression that evaluates to an integer, or a string as needed]
2) Creating New Objects
A) The new Operator
Once created, you can access the properties or methods of now just as any other Date object. Example:
You can create an entirely new object and define properties for it as well. Example:
var o=new Object();
o.someother=new Function('x','return x++;');
Which could then be referenced such as:
[Note- n=any integer or string as the function demands]
3) Object Classes
New objects are created as members of a class of objects who inherit certain predefined properties from their class. For example, a rectangle object would have height and width properties, and any rectangle object created dynamically would inherit these properties (but not their values of course). Example:
This will create a Rectangle class of objects:
var myRectangle=new Rectangle(2,6);
You could use any number of means to generate the new objects once their class is defined, allowing you to write full feature programs which dynamically create new usable objects and classes as needed.