Neil Mix wrote:
> The for/closures "bug" is definitely a newbie trap, but its pain is  
> not its discovery, but the difficulty of working around it.  To me  
> this could be a winning argument against re-binding on each loop,  
> since re-binding precludes the (admittedly dubious) use-case of  
> updating inside the body:
> 
> for (let i = 0; i < 100; i++) {
>    if (skipAhead) {
>      i += 9;
>      continue;
>    }
>    ...
> }

The expansions that MarkM and I posted work correctly in that case.

("Correctly" means what a C programmer would expect :-) To be more
specific, updates within the body take effect for the instance of
the variable that is seen by the update expression for the next
iteration.)

-- 
David-Sarah Hopwood
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to