title: Simple Array Length -always 0 even if content present
body: <p>I am facing some stupid issue for which I know I am missing something.</p>
  
  <p>I have a blank array in which I am pushing stuff using .push() method.</p>
  
  <p>Now When I print complete array, I get values, but when I use array.length then it is always zero. I know it is very silly something that I am missing.</p>
  
  <pre><code>var markersToPush = [];
  
  for (var i = 0; i &lt; contactList.length; i++) {
      console.log('conatcat addres', contactList[i].MailingStreet);
      geocoder.geocode({
          'address': contactList[i].MailingStreet
      }, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
              map.setCenter(results[0].geometry.location);
              var marker = new google.maps.Marker({
                  map: map,
                  position: results[0].geometry.location
              });
              markersToPush.push(marker.getPosition());
          } else {
              alert("Geocode was not successful for the following reason: " + status);
          }
      });
  }
  console.log('markers to push--&gt;', markersToPush);
  console.log('markers length--&gt;', markersToPush.length);
  </code></pre>
  
  <p>For result in log - </p>
  
  <p><a href="https://i.stack.imgur.com/Ee6hR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ee6hR.png" alt="enter image description here"></a></p>
  
  <p>I have already checked other linked issues - </p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/17019299/javascript-array-returns-length-as-0-always-even-there-are-elements-in-it">Javascript array returns length as 0 always even there are elements in it</a></li>
  <li><a href="https://stackoverflow.com/questions/17019299/javascript-array-returns-length-as-0-always-even-there-are-elements-in-it">Javascript array returns length as 0 always even there are elements in it</a></li>
  <li><a href="https://stackoverflow.com/questions/21356880/array-length-returns-0">Array Length returns 0</a></li>
  </ol>