Easy Tutorial
❮ Jsref Cos Prop Nav Appcodename ❯

JavaScript Array Property Constructor

JavaScript Array Object

Example

A new method for arrays that converts array values to uppercase:

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

Create an array and then call the myUcase method:

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

The fruits array now has the following values:

BANANA,ORANGE,APPLE,MANGO

Definition and Usage

The prototype property allows you to add properties and methods to objects.

When constructing a property, all arrays will be set with that property, which has a default value.

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

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

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


Browser Support

All major browsers support the prototype property.


Syntax


JavaScript Array Object

❮ Jsref Cos Prop Nav Appcodename ❯