title: Javascript: Return a promise inside async function
body: <p>Would it make any difference if I have:</p>
  
  <pre><code>async function test () {
    const foo = await bar()
    return Promise.all([promise1, promise2])
  }
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>async function test () {
    const foo = await bar()
    const [result1, result2] = await Promise.all([promise1, promise2])
    // Given that I don't care about result1, result2 in this `test` function
    return [result1, result2]
  }
  </code></pre>
  
  <p>I get the same result if I do either. E.g. I can do this for either case:</p>
  
  <pre><code>test().then(([result1, result2]) =&gt; { ... })
  </code></pre>
  
  <p>but I am more curious about the underlying mechanism how they both behave the same.</p>
  
  <p>In other words, how does async function handle it if inside the function I return a promise instead of a value?</p>