title: console.log doesn't wait "await" in async function
body: <p>I have this code</p>
  <pre><code>async function dataget(APIURL){
      let x = false;
      let xhr = new XMLHttpRequest();
      xhr.open(&quot;GET&quot;, APIURL);
      xhr.send();
      xhr.onload = await function(){
          if(1 == 1){
              x = true
          }else{
              x = &quot;gg&quot;
          }
      }
      console.log(x)
  }
  console.log(dataget(&quot;data.json&quot;));
  </code></pre>
  <p>I want console to wait until onload function ends (when x = true), but this doesn't happen,
  console returns false and doesn't wait</p>
  <p>this is the output:</p>
  <p><a href="https://i.stack.imgur.com/sz21p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sz21p.png" alt="enter image description here" /></a></p>
  <p>I want an explanation not just the solve</p>