[thelist] Using for loops with a twist

Christian Heilmann codepo8 at gmail.com
Tue Apr 3 04:17:39 CDT 2007


> When I run this it takes about 2200ms -- longer than for either of the
> other two.
>
>
> So, Christian, I admire your theory but I don't actually know if it
> helps!

Of course I have done the same, and also included for loops with
for-in (most expensive and slow) and while loops doing the same
conditional checking.

But here comes the catch: While this is true with real JS arrays try
it with a DOM nodelist and you will see that there is no speed
difference between "my" method and the backward looping or two
variable versions.

I didn't claim this to be a perfect solution, but I like the idea of
not having to read the length and being able to loop with a real
iterator and steps other than one.

-- 
Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/



More information about the thelist mailing list