Just wondering. I extended the JavaScript array object with my prototype as follows:
<html>
<head>
</head>
<body>
<script type="text/javascript">
function SomeMethod(){
alert('Hello');
}
if(typeof Array.prototype.SomeMethod ==='undefined' ){
Array.prototype.SomeMethod = SomeMethod;
}
var ax=new Array("A","B","C");
for(var i in ax){
document.write(ax[i]);
}
</script>
</body>
</html>
The result will be:
ABCfunction SomeMethod() { alert("Hello"); }
EDIT: Although I already found the answer, I feel the need to add some more information, so for others it would be clearer.
source
share