title: Breaking out of a PrototypeJS .each() loop
body: <p>In this very contrived example, I have an array with 3 elements that I'm looping over using the <a href="http://www.prototypejs.org/api/enumerable/each" rel="nofollow noreferrer"><code>.each()</code></a> method.</p>
  <pre><code>var vals = $w('foo bar baz'); 
  
  vals.each( function(val) {
      alert(val);
  
      if( val == 'bar' ) {
          //This exits function(val)
          //but still continues with the .each()
          return;
      }
  });
  </code></pre>
  <p>I can easily return out of the function being called by <strong><code>.each()</code></strong> if I need to.</p>
  <p>My question is, <strong>how can I break out of the <code>.each()</code> loop from inside the function that <code>.each()</code> is calling?</strong></p>