title: How to empty and delete an array with a parameter?
body: <h1>Problem</h1>
  
  <ol>
  <li>I can't empty an array with the <code>s</code> parameter</li>
  <li>I can't <code>delete</code> an array with the <code>deleteThis</code> parameter</li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>sentences = {
    all: [
      //1,000s of Sentences
      "This sentence meets all conditions.",
      "This sentence meets all conditions.",
      "This sentence failed.",
      "This sentence failed.",
      "This sentence meets all conditions.",
      "This sentence failed."
    ],
    success: [],
    failed: [],
    moveTo_then_Delete: []
  }
  
  
  
  
  function Divide_And_Empty(s, success, failed, deleteThis, regEx) {
    s.filter(function(str) {
      key = regEx.test(str)
      if (key) {
        success.push(str)
      } else {
        failed.push(str)
        deleteThis.push(str)
      }
    });
  
    //The code works correctly
    //All the way up until I try to empty and/or delete an array with parameter
    s = []
    delete deleteThis
  }
  Divide_And_Empty(sentences.all, sentences.success, sentences.failed, sentences.moveTo_then_Delete, /meets/)
  
  
  
  document.write("&lt;pre&gt;" + JSON.stringify(sentences, null, 2) + "&lt;/pre&gt;");</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>