title: Remove all query string in bulk from url?
body: <p>We want to remove multiple query string parameters from given url. For example:</p>
  
  <p>If url is: </p>
  
  <pre><code>https://www.example.com?budget=0-&amp;year=0-&amp;kms=0-&amp;so=-1&amp;sc=-1&amp;pn=1
  </code></pre>
  
  <p>and 
  if query string parameters to be removed are: "so","kms","pn", the output of that function should be: </p>
  
  <pre><code>https://www.example.com?budget=0-&amp;year=0-&amp;sc=-1
  </code></pre>
  
  <p>We have written following code for this:</p>
  
  <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>var input = "https://www.example.com?budget=0-&amp;year=0-&amp;kms=0-&amp;so=-1&amp;sc=-1&amp;pn=1";
  var url = input.replace('?', '');
  var removeFilterSet = {"so" : true,"kms" : true,"pn" : true};
  var params = url.split("&amp;");
  for(var i = params.length ; i-- &gt; 0  ; )
  {
      if(removeFilterSet[params[i].split("=")[0]])
      {
          params.splice(i,1);
      }
  }
  alert(params.join("&amp;"));</code></pre>
  </div>
  </div>
  </p>
  
  <p>Is there any better way to remove query string in bulk from url?</p>