title: Iterating through an object hashtable
body: <p>I am trying to use a hashtable so I can select a specific object stored in an array/object. However, I am having a problem looping through an object.</p>
  
  <pre><code>var pins= {};
  pins[6] = '6';
  pins[7] = '7';
  pins[8] = '8';
  
  $('#result3').append('&lt;div&gt;Size: ' + Object.size(pins) + '&lt;/div&gt;');
  for(var i = 0; i &lt; Object.size(pins); i++) {
      $('#result3').append('&lt;div&gt;' + pins[i] + '&lt;/div&gt;');
  }
  </code></pre>
  
  <p><strong>JSFiddle</strong>: <a href="http://jsfiddle.net/7TrSU/" rel="noreferrer">http://jsfiddle.net/7TrSU/</a></p>
  
  <p>As you can see in <code>TEST 3</code> which uses object <code>pin</code> to store the data, I am getting <code>undefined</code> when looping through the object <code>pin</code>. </p>
  
  <p>What is the correct way for looping through <code>pin</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>What happens if instead of just <code>pin[6] = '6'</code>, I make pin[6] = an object and I want to loop through the all their <code>id</code> properties? Actual code snippet of what I'm doing...</p>
  
  <pre><code>for(var i = 0; i &lt; json.length; i++) {
      markerId = json[i].listing_id
  
      // Place markers on map
      var latLng = new google.maps.LatLng(json[i].lat, json[i].lng);
      var marker = new google.maps.Marker({
                  listing_id: markerId,
                  position: latLng,
                  icon: base_url + 'images/template/markers/listing.png',
      });
  
      markers[markerId] = marker;
  }
  
  for(var marker in markers) {
      console.log('marker ID: ' + marker.listing_id);
      mc.addMarker(marker);
  }
  </code></pre>
  
  <p>The <code>console.log</code> above returns undefined, and if I do <code>console.log(marker)</code> instead, I get the value of <code>marker.listing_id</code>. Sorry I'm getting confused! </p>
  
  <p>I managed to get it to work with <code>$.each(markers, function(i, marker){});</code> but why does the <code>for..in</code> above not work?</p>