0

Is there a way to break out of the Qooxdoo qx.data.Array forEach loop?

For example,

 myarray.forEach(function(obj){
   if(obj.match(/ra/i)){
       //break out of the loop
   }
 }
Jonathan
  • 894
  • 2
  • 9
  • 20

2 Answers2

1

No, thats not possible. If you need that, you could think about using a regular for loop and break on the condition.

Martin Wittemann
  • 2,109
  • 1
  • 12
  • 14
0

Not sure about the version that existed in 2013 but currently there is the array method some. If you return a Boolean true from the function passed in, the loop will terminate.

myarray.some(function(obj) {
    if(obj.match(/ra/i))
    {
        // do something
        return true;
    }
}, this);