Help with removing __iterator__ from JS

Paolo Amadini paolo.01.prg at amadzone.org
Wed Jul 22 12:42:36 UTC 2015


On 7/21/2015 12:07 PM, Tom Schuster wrote:
> Aside: Please also try avoid using Iterator().

What would be the alternative to Iterator() when I need to iterate and
easily assign both keys and values of an object to local variables?

See for example <https://bugzilla.mozilla.org/show_bug.cgi?id=980828>:

   this.boundEventHandlers = [
     for ([elementName, events] of Iterator(this.events))
     for ([eventName, handler] of Iterator(events))
     [elementName, eventName, handler.bind(this)]
   ];

There's more context on the bug for the specific example (the bug is
about supporting destructuring in comprehensions in the first place)
but my concern in general is that I've failed to find an alternative
to Iterator() that is as expressive.

Cheers,
Paolo



More information about the firefox-dev mailing list