We might be able to figure out how to use Array.some() instead. Return
false for most iterations of the loop, and then return true when a "break"
is encountered (and return false when "continue" is encountered).
Replacing break and continue could be tricky, though, since they are
handled in a different sub-emitter.

- Josh

On Sun, May 8, 2016 at 11:49 PM, Harbs <harbs.li...@gmail.com> wrote:

> Rats. Good point…
>
> On May 9, 2016, at 8:12 AM, Alex Harui <aha...@adobe.com> wrote:
>
> > Isn't tan issue with Array.forEach() that you can't use 'break' to stop
> > the loop?
> >
> > -Alex
> >
> > On 5/8/16, 3:41 AM, "Harbs" <harbs.li...@gmail.com> wrote:
> >
> >> So would this be a workable solution?
> >>
> >> This:
> >>
> >> for each(item in object){
> >>      item.doSomething();
> >> }
> >>
> >> Would become:
> >>
> >> if (!!object.forEach){
> >>      object.forEach(function(item){
> >>              item.doSomething();
> >>      });
> >> } else {
> >>      var foreachiter0_target = object;
> >>      for (var foreachiter0 in foreachiter0_target)
> >>      {
> >>              var item = foreachiter0_target[foreachiter0];
> >>              item.doSomething();
> >>      }
> >> }
> >>
> >> I could add a forEach method to XMLList objects and then we would not
> >> need to do compile time checks for XML. (at least for cases of for each)
> >>
> >> On May 8, 2016, at 3:16 AM, Josh Tynjala <joshtynj...@gmail.com> wrote:
> >>
> >>> The array forEach() seems like an acceptable alternative. Looking at
> MDN
> >>> [1], forEach is widely supported in browsers. Including IE 9.
> >>>
> >>>
> >>>
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_
> >>> Objects/Array/forEach
> >>>
> >>> - Josh
> >>>
> >>> On Sat, May 7, 2016 at 4:32 PM, lizhi <s...@qq.com> wrote:
> >>>
> >>>> 10x slow.
> >>>> maybe use the arr.forEach.
> >>>> pls run this code
> >>>>
> >>>> https://gist.github.com/matrix3d/a9765b94ade3d626ad64d16f28deccae
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> View this message in context:
> >>>>
> >>>>
> http://apache-flex-development.2333347.n4.nabble.com/flexjs-foreach-very
> >>>> -slow-tp52571p52880.html
> >>>> Sent from the Apache Flex Development mailing list archive at
> >>>> Nabble.com.
> >>>>
> >>
> >
>
>

Reply via email to