forEach() trouble when an element is removed during execution

Jason Orendorff jason.orendorff at
Mon Jun 18 11:05:12 PDT 2007

On 6/18/07, Peter Michaux <petermichaux at> wrote:
> I don't think that fixing this edge case to make a very robust forEach
> would be a bad idea. I think having a very robust forEach (similar to
> the DOM2 iteration over handlers) would be much better and make the
> language more self-consistent.

For self-consistency, I think the most important thing is that
"forEach()" and "for each" behave the same way.  Do you agree?

I mean, these two things should work the same:

  this.observers.forEach(function(o) {o();});

  for each (let o in this.observers) o();

My point is, I think you're proposing a change to Array iterators,
not just a change to forEach().


More information about the Es4-discuss mailing list