title: How to get value in an object's key using a variable referencing that key?
body: <p>I have an object and I can reference key <code>a</code> as in the following:</p>
  <pre class="lang-js prettyprint-override"><code>var obj = {
     a: &quot;A&quot;,
     b: &quot;B&quot;,
     c: &quot;C&quot;
  }
  
  console.log(obj.a); // return string : A
  </code></pre>
  <p>I want to get the value by using a variable to reference the object key as below:</p>
  <pre class="lang-js prettyprint-override"><code>var name = &quot;a&quot;;
  console.log(obj.name) // this prints undefined, but I want it to print &quot;A&quot;
  </code></pre>
  <p>How can I do this?</p>