title: How can I return all previous items in a JavaScript array than a current value?
body: <p>Let's say I have an array:</p>
  
  <pre><code>var myArr = new Array('alpha','beta','gamma','delta');
  </code></pre>
  
  <p>And that I want a function to return an array of all items before a given item:</p>
  
  <pre><code>function getAllBefore(current) {
      var myArr = new Array('alpha','beta','gamma','delta');
      var newArr = ???
      return newArr;
  }
  
  getAllBefore('beta'); // returns Array('alpha');
  getAllBefore('delta'); // returns Array('alpha','beta','gamma');
  </code></pre>
  
  <p>What's the fastest way to get this?  Can I split an array on a value?  Do I have to loop each one and build a new array on the fly?  What do you recommend?</p>
  
  <p>What about if I wanted the opposite, i.e. <code>getAllAfter()</code>?</p>