title: jQuery skip an iteration of the parent loop in nested .each
body: <p>I have the following construct:</p>
  
  <p><strong>Note</strong>: the arrays and the goal in this example are only symbolic! I know that there would be way better solutions for this example - it's just to demonstrate the construct of the code.</p>
  
  <pre><code>var firstArray = [1,2,3,4,5];
  var secondArray = [1,2,4,5];
  
  $.each(firstArray,function(i,firstArrayElement){
      $.each(secondArray,function(i,secondArrayElement){
          if(firstArrayElement === secondArrayElement) {
              // do stuff
  
              // PROBLEM: force the firstArray loop to continue with the next iteration
          }
      });
      console.log("Didn't find: "+firstArrayElement);
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/utfd058e/" rel="nofollow noreferrer">jsFiddle</a></p>
  
  <p>To clarify my question: Is there a way to force the parent .each to continue (= skip the <code>console.log</code>) with the next iteration? In PHP this would be <code>continue 2;</code>. So the goal is, to never reach the <code>console.log()</code> if a condition is true (in this example an element is found).</p>
  
  <p>There is <a href="https://stackoverflow.com/questions/12161913/how-to-break-out-from-outer-each-loop">the flag</a> solution (<a href="http://jsfiddle.net/v1rvuzu6/" rel="nofollow noreferrer">jsFiddle</a>), but there has to be a nicer way to do this.</p>
  
  <p>There are also <a href="https://stackoverflow.com/questions/1564818/how-to-break-2-loops-in-javascript?answertab=votes#tab-top">solutions with labels</a> but labels won't work with .each().</p>
  
  <p>So what I am looking for is probably a way to use <code>return</code> in the parent function without flags. For the example above, this would mean that the result logs: <code>Didn't find 3</code></p>