I noticed that whenever i modify an array prototype it changes the behavior of foreachs. I have created the example below to show you guys what im doing:
Array.prototype.x = 10;
for(var i in [1,2,3]){
alert(i);
}
This example shows four alerts: "1", "2", "3" and "x";
Why this code give me 4 alerts?
How can i modify array prototype without interfere with the foreach ?
Array.prototypewithout making the extensions enumerable; see bfontaine's correct answer below.