title: How can I use async/await at the top level?
body: <p>I have been going over <code>async</code>/<code>await</code> and after going over several articles, I decided to test things myself. However, I can't seem to wrap my head around why this does not work:</p>
  <pre class="lang-js prettyprint-override"><code>async function main() {  
      var value = await Promise.resolve('Hey there');
      console.log('inside: ' + value);
      return value;
  }
  
  var text = main();  
  console.log('outside: ' + text);
  </code></pre>
  <p>The console outputs the following (node v8.6.0) :</p>
  <blockquote>
  <p>&gt; outside: [object Promise]</p>
  <p>&gt; inside: Hey there</p>
  </blockquote>
  <p>Why does the log message inside the function execute afterwards? I thought the reason <code>async</code>/<code>await</code> was created was in order to perform synchronous execution using asynchronous tasks.</p>
  <p>Is there a way could I use the value returned inside the function without using a <code>.then()</code> after <code>main()</code>?</p>