Latest web development tutorials

JavaScript Array attribute constructors

Array Object Reference Manual JavaScript array of objects

Examples

A new method of the array, the 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 myUcase methods:

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

an array of fruits is now:

BANANA,ORANGE,APPLE,MANGO

try it"

Definition and Usage

prototype property gives you the ability to add properties and methods to an object.

When building a property, all of the array will be set up property, which is the default.

In constructing a method, all of the arrays can use this method.

Note: Array.prototype alone can not reference an array, Array () object.

Note: JavaScript objects, Prototype is a global property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support prototype property.


grammar

Array.prototype.Name = value


Array Object Reference Manual JavaScript array of objects