There's a method to iterate over only own object properties, not including prototype's ones:
for (var i in array) if (array.hasOwnProperty(i)) {
// doDo something with array[i]
}
but it still will iterate over custom-defined properties.
In javascriptJavaScript any custom property could be assigned to any object, including an array.
If one wants to iterate over sparsed array, for (var i = 0; i < array.length; i++) if (i in array)
or array.forEach
with es5shim
should be used.