Accessing Properties in object
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4968406/javascript-property-access-dot-notation-vs-brackets">JavaScript property access: dot notation vs. brackets?</a>  </p>
</blockquote>



<pre><code>&lt;script&gt;      
  var foo = {          
    name: 'kevin'        
  };

  document.write(foo.name);
  document.write(foo['name']);

  var cool = 'name';
  document.write(foo.cool);

  document.write(foo[cool]);      
&lt;/script&gt;
</code></pre>

<ol>
<li>Why does <code>foo.cool</code> returns me undefined where as <code>foo[cool] returns
me kevin</code>.</li>
<li>How does cool actually refer to my name property in foo object.</li>
</ol>
