title: Async await in map function not executing in order
body: <p>I have the follow code below:</p>
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="true">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = [
      { condition: true, recursion: [], result: 'OLD_RESULT', recursiveArray: [{condition: true, result: 'OLD_RESULT'}] },
      {condition: false, result: 'OLD_RESULT'},
      { condition: true, recursion: [], result: 'OLD_RESULT', recursiveArray: [{condition: true, result: 'OLD_RESULT'}] },
      {condition: false, result: 'OLD_RESULT'},
  ];
  
  var someAsyncCall = async () =&gt; {
      return 'NEW VALUE';
  };
  
  var asyncInMap = (arr) =&gt; {
      return arr.map(async (elem) =&gt; {
          const condition = elem.condition;
          if (condition) {
              const result = await someAsyncCall();
              elem.result = result;
          }
          if (elem.recursiveArray) {
              elem.recursion = asyncInMap(elem.recursiveArray);
          }
          console.log('SECOND:', elem);
          return elem;
      });
  };
  
  console.log('FIRST');
  var promisesVal = asyncInMap(arr);
  console.log('THIRD');
  var completedVal = await Promise.all(promisesVal);
  console.log('FOURTH', completedVal);</code></pre>
  </div>
  </div>
  </p>
  <p>My question is in the order of the <code>console.log's</code> I am getting:</p>
  <pre><code>FIRST
  SECOND: {condition: false, result: &quot;OLD_RESULT&quot;}
  SECOND: {condition: false, result: &quot;OLD_RESULT&quot;}
  THIRD
  SECOND: {condition: true, recursion: Array(1), result: &quot;NEW VALUE&quot;, recursiveArray: Array(1)}
  SECOND: {condition: true, recursion: Array(1), result: &quot;NEW VALUE&quot;, recursiveArray: Array(1)}
  SECOND: {condition: true, result: &quot;NEW VALUE&quot;}
  SECOND: {condition: true, result: &quot;NEW VALUE&quot;}
  FOURTH (4) [{…}, {…}, {…}, {…}]
  </code></pre>
  <p>Why is the <code>Third</code> log being printed before all the <code>Second</code> <code>console.log</code> are done? Is this because I am using recursion inside of the <code>asyncInMap</code> function along with <code>async/await</code>? Ideally the <code>asyncInMap</code> should be completed (with all the <code>Second</code> logs printed first) and then only the <code>Third</code> log should be printed correct?</p>