JScript Language Elements

| Tutorial | Reference |

Objects

| Objects | Built-In Objects | Creating Your Own Objects |

What are JScript objects?
Objects are, essentially, collections of properties and methods. For example, Math.SQRT2 is a property of the Math object, and aString.substring() is the substring method of the string object, as it exists in the instance aString.

Properties:
The properties of an object can be values, functions, and even other objects. For example, you could construct a "toDoToday" object that would have an instance of the Date object as one of its properties.

Objects as Arrays
In JScript, objects can be handled as arrays. That is to say, you can refer to any of the constituents of an object (its properties and methods) either by name or by its array subscript number. Subscripts in JScript begin with 0. For convenience, the subscript can also be referred to by its name.

Thus, a property can be referred to in several ways. The following examples use an instance of the pasta object, which is defined in the section on creating your own objects.

EXAMPLES:
theWidth = spaghetti.width;
// - or -
theWidth = spaghetti[3];
// - or -
theWidth = spaghetti["width"];



© 1996 by Microsoft Corporation.