title: Javascript "multidimensional" array behaving differently based on location in script
body: <p>I've created a &quot;multidimensional&quot; JS array with a function. Within that function, the console log shows the array with all elements as I would expect it.</p>
  <p>Outside of the function, I can still show the array in the console, but it looks different, and I can't access elements with the typical arr[0] identifiers.</p>
  <p>Any ideas what might be going on? I need to be able to access this array globally. Please be patient with me, I'm new and green.</p>
  <pre><code>var thisQsetTrue = [];
  var thisQsetFalse = [];
  //Start getDoc
  function getDoc() {
      const xhttp = new XMLHttpRequest();
      xhttp.onload = function() {
          buildArray(this);
      }
      xhttp.open(&quot;GET&quot;, &quot;AddisonNovice.xml&quot;);
      xhttp.send();
  }
  //End get Doc
  //Start buildArray
  function buildArray(xml) {
      const xmlDoc2 = xml.responseXML;
      const y = xmlDoc2.getElementsByTagName(&quot;question&quot;);
      //Build the true answer array
      for (let i = 0; i &lt;y.length; i++) {
          var tempArray = [];
          if (y[i].getElementsByTagName(&quot;type&quot;)[0].childNodes[0].nodeValue == &quot;true&quot;) {
              tempArray.push(y[i].getElementsByTagName(&quot;query&quot;)[0].childNodes[0].nodeValue);
              tempArray.push(y[i].getElementsByTagName(&quot;feedback&quot;)[0].childNodes[0].nodeValue);
              thisQsetTrue.push(tempArray);
          }
      }
      //Build the false answer array
      for (let i = 0; i &lt;y.length; i++) {
          var tempArray2 = [];
          if (y[i].getElementsByTagName(&quot;type&quot;)[0].childNodes[0].nodeValue == &quot;false&quot;) {
              tempArray2.push(y[i].getElementsByTagName(&quot;query&quot;)[0].childNodes[0].nodeValue);
              tempArray2.push(y[i].getElementsByTagName(&quot;feedback&quot;)[0].childNodes[0].nodeValue);
              thisQsetFalse.push(tempArray2);
          }
      }
      console.log(thisQsetFalse);//Array displays normally
  }
  //End buildArray
  //Call getDoc
  getDoc();
  console.log(thisQsetFalse);//Array displays differently
  </code></pre>
  <p>Console log screenshot. As you can see, all the elements of the array are there, but it looks different, and I can't get to the elements:
  <a href="https://i.stack.imgur.com/V5ZXs.png" rel="nofollow noreferrer">Screenshot of console log</a></p>