JavaScript Array PropertyConstructor

Array Object 参考手册JavaScript Array Object

Instance

A new array method that converts array values to uppercase:

Array.prototype.myUcase=function() { for (i=0;i<this.length;i++) { this[i]=this[i].toUpperCase(); } }

Create an array, then call the myUcase method:

var fruits=["Banana","Orange","Apple","Mango"]; fruits.myUcase();

fruitsThe array's current value is:

BANANA,ORANGE,APPLE,MANGO

Try it yourself »

Definition and Usage

The prototype property gives you the ability to add properties and methods to objects.

When constructing a property, all arrays will be set with that property, and it is the default value.

When constructing a method, all arrays can use that method.

Note:Array.prototype alone cannot reference an array; the Array() object can.

Note:In JavaScript objects, Prototype is a global property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the prototype property.


Syntax

Array.prototype.name=value


Array Object 参考手册JavaScript Array Object

Other Extensions