for own(...) loop (spin-off from Re:, hasOwnProperty(), and inheritance)

Brendan Eich brendan at
Wed Nov 9 13:20:48 PST 2011

On Nov 9, 2011, at 1:15 PM, Dean Landolt wrote:

> On Wed, Nov 9, 2011 at 4:05 PM, Brendan Eich <brendan at> wrote:
> On Nov 9, 2011, at 12:40 PM, Jorge wrote:
> > On 08/11/2011, at 22:17, John J Barton wrote:
> >> Just as a point of comparison, I use this form:
> >>  Object.keys(o).forEach( function(key) {
> >>     body
> >>  });
> >
> > By the way, isn't that above a(nother) good use case for a goto, given that there's no (easy) way to break out of a forEach 'loop' ?
> "goto" as in C, from body to a label in the outer function or script? Seriously?
> You could always use try/catch/throw, but who would?
> Umm, es-next, right? In a way, isn't this what StopIteration is? :)

No, that's almost entirely under the for/of hood. The number of users who have to manually catch in order to write schedulers is miniscule compared to the population who'll write loops, comprehensios, and generator expressions.

> Still, it's a whole lot nicer to just let the language do your try/catch wrapping where you can.


> And if you need to break out of forEach, just, umm, don't use forEach. It's the wrong tool for the job.

Clearly people like the forEach array extra in conjunction with Object.keys. With block-lambdas they could have their cake and break from it too (and the call would be paren-free to boot).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list