The reason is that one construct: var a = []; // Create a new empty array. a[5] = 5; // Perfectly legal JavaScript that resizes the array. for (var i = 0; ... ... <看更多>
It also goes up to the prototype chain and enumerates over inherited properties. Avoid using for...in loop to iterate over elements of an array, especially when ... ... <看更多>
A for-in loop ( for (var k in o) ) iterates over the properties of an Object. While it is legal to use for-in loops with array types, it is not common. ... <看更多>