The problem is that even if the logic in the loop body doesn't cause an infinite loop; you are at the very least also iterating over all the additional elements that you push for no good reason. You've just pushed those values; you presumably don't want them to cause further pushes.
Why do pointless extra work when it is so easily avoided?
In reply to Re^3: Is it safe to append to the array you are iterating over
by BrowserUk
in thread Is it safe to append to the array you are iterating over
by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |