title: Best es6 way to get name based results with Promise.all
body: <p>By default the Promise.All([]) function returns a number based index array that contains the results of each promise.</p>
  
  <pre><code>var promises = [];
  promises.push(myFuncAsync1()); //returns 1
  promises.push(myFuncAsync1()); //returns 2
  Promise.all(promises).then((results)=&gt;{
      //results = [0,1]
  }
  </code></pre>
  
  <p><strong>What is the best vanilla way to return a named index of results with Promise.all()?</strong></p>
  
  <p>I tried with a Map, but it returns results in an array this way: 
  <code>[key1, value1, key2, value2]</code></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><strong>My questions seems unclear, here is why i don't like ordered based index:</strong></p>
  
  <ol>
  <li><strong>it's crappy to maintain</strong>: if you add a promise in your code you may have to rewrite the whole results function because the index may have change.</li>
  <li><strong>it's awful to read</strong>: <code>results[42]</code> (can be fixed with jib's answer below)</li>
  <li><strong>Not really usable in a dynamic context</strong>:</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>var promises = [];
  if(...)
      promises.push(...);
  else{
      [...].forEach(... =&gt; { 
          if(...)
              promises.push(...);
          else
              [...].forEach(... =&gt; {
                  promises.push(...);
              });
      });
  }
  Promise.all(promises).then((resultsArr)=&gt;{
      /*Here i am basically fucked without clear named results 
          that dont rely on promises' ordering in the array */
  });
  </code></pre>