Just wonder.
I have extended javascript Array object using its 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 have already found the answer I feel the necessity to add some
more information so it would be clearer for others.
for..initerates over the (non built-in) properties of an object. Do not use it to iterate through an array. Just use a regularforloop.Read this link https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for…in#Description