title: Breaking out of an inner foreach loop
body: <p>I am trying to break out of an inner foreach loop using JavaScript/jQuery.</p>
  
  <pre><code>result.history.forEach(function(item) {
      loop2:
      item.forEach(function(innerItem) {
          console.log(innerItem);
          break loop2;
      });
  }); 
  </code></pre>
  
  <p>This is resulting in the error <code>'Unidentified label loop2'</code>. it appears to be right before the loop which was what other questions were saying was the issue.</p>
  
  <p>What am I doing wrong and how do I fix it?</p>
  
  <p>Edit: Correct, the foreach loop cant break in this way but a regular for loop can. This is working:</p>
  
  <pre><code>                        result.history.forEach(function(item) {
                              loop2:
                              for (var i = 0; i &lt; item.length; i++) {
                                  var innerItem = item[i];
                                  console.log(innerItem);
                                  break loop2;
                              }
                          });
  </code></pre>