- From: Erik Arvidsson <arv@chromium.org>
- Date: Mon, 26 Apr 2010 09:43:40 -0700
>> 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
Received on Monday, 26 April 2010 09:43:40 UTC