title: Array of Objects Built Inside Functions has Type Issues
body: <p>I'm making nested API calls and putting pieces of the result in an array of objects. When I print this out to the console, it looks fine. But when I try to call functions on the pieces, they break.</p>
  
  <p>Here's the code except for the private API URL:</p>
  
  <pre><code>var gate = new Array();
  
  jQuery.getJSON(endPoint + "method=GetUsersWithTicketsEventId", function(tickets) {
    jQuery.each(tickets.message, function(i, ticket) {
      gate[i] = new Object();
  
      jQuery.getJSON(endPoint + "method=GrabUsersCustomEventInfo&amp;userId=" + ticket.UserId, function(answers) {
          jQuery.each(answers.message, function(j, answer) {
          if (answer.meta_key == "42_Volunteering") {
            if (answer.meta_value != "Array") {
              gate[i].Roles = answer.meta_value.split(';');
            } else {
              gate[i].Roles = new Array();
            }
          } else if (answer.meta_key == "42_1_TOSDate") {
              gate[i].Date = new Date(answer.meta_value);
          }
  
          console.dir(gate[0].Date); // This works
        });  
      });
  
    });
  
    console.dir(gate); // This works
    console.dir(gate[0].Date); // This returns undefined
  });
  </code></pre>
  
  <p>The results of the second console.dir() seem to be well formed:</p>
  
  <pre><code>&gt; Array(237)
    &gt; [0 … 99]
      &gt; 0: Object
        &gt; Date: Mon May 08 2017 21:09:09 GMT-0700 (Pacific Daylight Time)
          &gt; __proto__: Object
            &gt; constructor: function Date()
  ...
  </code></pre>
  
  <p>I assume this has something to do with variable scope, but I don't understand how to debug it when the console output is so obviously different from what the interpreter is seeing.</p>