I don't know about JavaScript, but in C#, you cannot modify a collection as you're enumerating it.
So this code is not valid:
foreach(string s in MyStringList)
{
MyStringList.Remove(s); // throws an exception
}
So yes, you will have to use a regular for loop (not foreach) to enumerate your array/collection, and I believe the same applies to Javascript (since it's all compiled down to Mono anyway).