How do I get URL query parameters into an object literal?
<p>When looking at location.search, what's the best way to take the query parameters and turn them into an object literal? Say I've got a URL that looks like this:</p>

<blockquote>
  <p><a href="http://foo.com?nodeId=2&amp;userId=3&amp;sortOrder=name&amp;sequence=asc" rel="nofollow">http://foo.com?nodeId=2&amp;userId=3&amp;sortOrder=name&amp;sequence=asc</a></p>
</blockquote>

<p>What I'd like to wind up with is an object literal that looks like this:</p>

<pre><code>var params = {
  nodeId : 2,
  userId : 3,
  sortOrder: name,
  sequence: asc
}
</code></pre>

<p>So I'd like to do something like this:</p>

<pre><code>var url = location.search;
url = url.replace('?', '');
var queries = url.split('&amp;');
var params = {};
for(var q in queries) {
var param = queries[q].split('=');
params.param[0] = param[1];
</code></pre>

<p>};</p>

<p>But this line:</p>

<pre><code>params.param[0] = param[1]
</code></pre>

<p>generates an error. How do you iterate through those keys if you don't know the key names?</p>

<p>We're using jQuery, and I'm sure there's a plugin to do this, but I'd like to understand how to program this anyway.</p>
