Accessing a property when I have its name in a variable
<p>I have an object like this:</p>

<pre><code>var items = {
  foobar: {
    foo: 'bar'
  }
}</code></pre>

<p>and I have the name 'foobar' in a value I receive when the user selects it in a form, like this:</p>

<p><code>var item = $('select').val(); // which is 'foobar'</code></p>

<p>How can I access <code>items.foobar.foo</code> when I only know the name 'foobar' in that variable? It won't parse 'item' as a variable in <code>items.item.foo</code>...</p>

<p>I guess it's kinda like doing <code>$items[$item]['foo']</code> in PHP, but I have no idea how do do it in Javascript.</p>

<p>Thanks.</p>
