The prototype property allows you to add new properties and methods to the Array() object.
The prototype property allows you to add new properties and methods to the Array() object.
When adding a property, all array objects will be given the property, and its value, as default.
When adding a method, all array objects will have this method.
Array.prototype refers to the Array class itself.
Array.prototype.name = value
Make a new array method that transforms array values into upper case:
Array.prototype.myUcase = function() { var i;/*from www .j a v a 2 s .co m*/ for (i = 0; i < this.length; i++) { this[i] = this[i].toUpperCase(); } }; var myArray = ["XML", "Json", "Database", "Mango"]; myArray.myUcase(); console.log( myArray );