I was looking to make my code look more readable by “cleverly” using for (var x in array)
loops instead of for (var x=0; x < array.length; x++)
, even though the shorter for loops are not supposed to be used with arrays, but used only with objects.
Turns out that jquery/prototypeJS put in extra hidden variables inside the array. If for whatever reason you are not using a JavaScript framework/library, you can use cross-browser shortcut: for (var x in array)
. However, be cautioned JavaScript experts are particularly annoyed by it.