title: Remove Whitespace-only Array Elements
body: <p>Since using array.splice modifies the array in-place, how can I remove all whitespace-only elements from an array without throwing an error? With PHP we have preg_grep but I am lost as to how and do this correctly in JS.</p>
  
  <p>The following will not work because of above reason:</p>
  
  <pre><code>for (var i=0, l=src.length; i&lt;l; i++) {
  
      if (src[i].match(/^[\s\t]{2,}$/) !== null) src.splice(i, 1);
  
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot call method 'match' of undefined</p>
  </blockquote>