This is the piece code to show my question:
var data=[];
for(var pro in data) {
console.log('Property: '+pro);
}
Array.prototype.Dummy=function() {
};
for(var pro in data) {
console.log('Property:'+pro);
}
I expect the 2 for in statements behave the same, the first prints nothing, reasonable, but the second one will list 'Dummy' only as the array's property, even Array has lots of buildin methods.
The user defined method is different from build in, why?
The reason I ask this question is that I use 3 party libraries, if I extend buildin data types(like Array, Date ect.), I'll potentially modify what their for in statements do.