[thelist] Using for loops with a twist

Jason Handby jason.handby at corestar.co.uk
Tue Apr 3 04:25:05 CDT 2007

> > 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.

Ah, that's interesting, I guess perhaps there's something about DOM
nodelists that makes calculating the length of them more expensive...

> 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.

It's an interesting post, and an interesting idea. I'm sure I came up
against a similar issue in C# not long ago, and reading your post has
made me want to go back and recode it :-)


More information about the thelist mailing list