Ticket #3776 (closed bug: invalid)
$.each iterator extremely inefficient with arrays with no values at lower index positions
|Reported by:||mmikeyy||Owned by:|
and it is not only inconvenient: it seems to be a bug.
The $.each function executes the function supplied as a 2nd parameter even for array positions that have never been filled (the 2nd argument passed to this function is then "undefined"). Why use the very efficient JQuery syntax if we end up having to write a more complex function to handle non-existing data?
Also, since the $.each function wastes time iterating over non-existing array elements, it can easily be HUNDREDS of times slower than the standard JS for(ind in array) construct, which is not affected by this problem.
On my computer with Firefox 3, iterating 100 times over a 2-element array with the highest index equal to 5000 takes... not even 1 ms with "for(ind in array)", and it takes 679 ms with $.each.