please dont rip this site
Microsoft® JScript™
JScript Objects
 JScript Tutorial 
 Previous | Next 


What Are Objects?
In Microsoft JScript, objects are, essentially, collections of properties and methods. A method is a function that is a member of an object, and a property is a value or set of values (in the form of an array or object) that is a member of an object. JScript supports three kinds of objects: intrinsic objects, objects you create, and browser objects, which are covered elsewhere.

Objects as Arrays
In JScript, objects and arrays are handled identically. You can refer to any of the members of an object (its properties and methods) either by name (using the name of the object, followed by a period, followed by the name of the property) or by its array subscript index. Subscript numbering in JScript begins with 0. For convenience, the subscript can also be referred to by its name.

Thus, a property can be referred to in several ways. All of the following statements are equivalent.

theWidth = spaghetti.width;
theWidth = spaghetti[3];  // [3] is the "width" index.
theWidth = spaghetti["width"];
While it is possible to use brackets to refer to a property by its numeric index, it is not possible to use the dot (.) convention with index numbers. The following statement generates an error.

theWidth = spaghetti.3;
When an object has another object as a property, the naming convention extends in a straightforward way.

var init4 = toDoToday.shoppingList[3].substring(0,1);  // shoppingList, an array, is a property of toDoToday.
The fact that objects can have other objects as properties lets you generate arrays with more than one subscript, which are not directly supported. The following code creates a multiplication table for values from 0 times 0 through 16 times 16.

var multTable = new Array(17);  // Make the shell that will become the table.
for (var j = 0; j < multTable.length; j++)  {  // Prepare to fill it with rows.
    var aRow = new Array(17);  // Create a row.
    for (var i = 0; i < aRow.length; i++)  {  // Prepare to fill the row.
    aRow[i] = (i + " times " + j + " = " + i*j);  // Make and place one value.
    }
multTable[j] = aRow;  // Put the filled row into the table.
}
To refer to one of the elements of an array of this kind, use multiple sets of brackets.
var multiply3x7 = multTable[3][7];
The following statement generates an error.
var multiply3x7 = multTable[3, 7];

© 1997 by Microsoft Corporation. All rights reserved.


file: /Techref/language/jscript/js919.htm, 4KB, , updated: 1997/9/30 02:45, local time: 2024/11/16 05:35,
TOP NEW HELP FIND: 
3.14.135.52:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/techref/language/jscript/js919.htm"> JScript Objects</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?