JavaScript Array property constructor
Example
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
(
)
;
fruits The array values are now:
BANANA,ORANGE,APPLE,MANGO
Try it »
Definition and Usage
The prototype property allows you to add properties and methods to an object.
When a property is constructed, all arrays get this property as the default value.
When a method is constructed, all arrays can use that method.
Note: Array.prototype alone cannot refer to an array; the Array() object can.
Note: In JavaScript objects, Prototype is a global property.
Browser support





All major browsers support the prototype property.
Syntax
Array.prototype.
name
=
value
JavaScript Array object