title: Javascript array length of 0
body: <p>I am getting some weird behaviour with the following, it shows an array length of 0 eventhough printing it right before that shows that there clearly is a length greater than 0:</p>
  <pre><code>var getTopSelection = function(callback) {
      var topSelection = [];
      for(var i=0; i &lt; markers.length; i++) {
          if(markers[i].map !== null) {
              var stationID = markers[i].id;
              getTrips(stationID, globalFromDate, globalToDate, function(response) {
                  topSelection.push({
                      StationID: stationID,
                      Trips: response
                  });
              }, function(error) {
                  console.log(error);
              })
          }
      }
      callback(topSelection);
  };
  
  getTopSelection(function(response) {
              console.log(response); //115
              console.log(response.length); //116
  })
  </code></pre>
  <p>And this is shown in the inspector, the &quot;length: 42&quot; belongs to line 115.</p>
  <p><a href="https://i.stack.imgur.com/0mgVO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0mgVO.png" alt="enter image description here" /></a></p>
  <p>Question: Why does it show a length of 0 eventhough it clearly says it has a length of 42 one line before?</p>