Microsoft® JScript™ prototype Property |
| Language Reference | | Version 2 | |
Contains a reference to the prototype for a class of objects.
functionname.prototype
Use the prototype property to provide a base set of functionality to a class of objects. The members of the object declared as the prototype for an object type are "inherited" by every new instance of that object type.For example, say you wanted to add a method to the Array object that returned the value of the largest element of the array. To do this, declare the function, add it to Array.prototype, and then use it.
After this code executes, y contains the largest value in the array x, or 6.function array_max( ) { // Function code. } Array.prototype.max = array_max; var x = new Array(1, 2, 3, 4, 5, 6); var y; x.max( );JScript does not support prototypes of the Number and Function objects.
© 1997 Microsoft Corporation. All rights reserved. |