--- In [email protected], "Josh McDonald" <[EMAIL PROTECTED]> wrote:
>
> *nods*
> 
> I find that it's often much easier to read when you use for..in and 
for
> each..in rather than regular for. And since you need to have a "var 
current
> = list[i]" or similar as the first line, If you only need an index 
to
> display, or it's 1-based as opposed to 0-based, using a "for 
[each]..in" and
> having the first inner line be "++idx" will be easier to read than 
a bunch
> of statements within your loop that look like:
> 
> var current = foo[i+1]
> 
> or
> 
> msg = "you're at item #" + (i + 1)

The thing is, I nearly always find I need that i for something else 
other than just iterating, so even when I start out with a for each 
loop, about 80% of the time I wind up switching back so I have that i 
to get hold of.  Since I know that this is quite likely to happen, I 
just "cut to the chase" and use the indexed loop.

-Amy

Reply via email to