title: javascript - dot vs bracket notation in enumeration
body: <p>I do know there's some differences between dot and bracket notations but for this specific problem I am a bit confused why the dot notation wouldn't work and bracket does.</p>
  
  <pre><code>var rockSpearguns = {
    Sharpshooter: {barbs: 2, weight: 10, heft: "overhand"},
    Pokepistol: {barbs: 4, weight: 8, heft: "shoulder"},
    Javelinjet: {barbs: 4, weight: 12, heft: "waist"},
    Firefork: {barbs: 6, weight: 8, heft: "overhand"}
  };
  
  function listGuns (guns) {
      for(var speargun in guns){
          console.log("Behold! "+speargun+", with "+ guns[speargun].heft +" heft!");
      }
  }
  </code></pre>
  
  <p>the part I am a bit confused is <code>guns[speargun].heft</code> this would work properly but if I do <code>guns.speargun.heft</code> then it will be undefined.</p>
  
  <p>Since the properties in the rockSpearguns are all just one word shouldn't <code>gun.speargun</code> still able to call out the properties too?</p>
  
  <p>I have thought a bit was the reason because now <code>speargun</code> is a string that if putting into <code>gun.speargun</code> it actually becomes something like <code>gun."speargun"</code> because if using bracket notation we just do <code>gun[speargun]</code> instead of using <code>gun["speargun"]</code> because this will just make it a double quote which is wrong.</p>