[whatwg] Adding ECMAScript 5 array extras to HTMLCollection
Erik Arvidsson
arv at chromium.org
Mon Apr 26 09:43:40 PDT 2010
>> for (var i = 0, length = collection.length; i < length; i++)
>> // instead of:
>> for (var i = 0; i < collection.length; i++)
>>
>
> Actually, the former is a problem when the nodelist is modified in the
> loop; it may result in collection[i] being undefined.
Even when checking the length in every iteration you can run into
problems. If you remove something earlier in the collection you will
*miss* one item unless you fix the loop iterator.
We should not let these edge cases get in the way of making the DOM
collections feel less foreign to JavaScript.
--
erik
More information about the whatwg
mailing list