title: Does the execution finishes after the very first promise is resolved(rejected) in Promise.race?
body: <p>I can't understand what's <code>Promise.race</code> behavior. Does it stop after the very first promise instance in an array of promises is resolved (rejected), ignoring all the rest?</p>
  
  <p><strong>My goal is</strong> to execute all promises in an array. In any sequence but all should be executed.</p>
  
  <p>An example. Lets say that <code>array_of_urls</code> has 10 urls. Will <code>Promise.race</code> execute all 10 promises, in any sequence one by one, or will it stop after the very first?</p>
  
  <pre><code>.then(array_of_urls =&gt; {
  
      // array_of_urls == [10 urls]
      let array_of_promises = array_of_urls.map((url) =&gt; {
          return fetch(url).then(res =&gt; {
              return res;
          });
      });
  
      return Promise.race(array_of_promises);
  })
  .then(each_and_every_result =&gt; {
  
      // What does happen here? Will this `then` callback be called 10 times or just one?
  
  })
  </code></pre>
  
  <p>Do <code>Promise</code>s have methods to execute all? </p>
  
  <p>PS:</p>
  
  <p>MDN <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise/race#Description" rel="nofollow">doesn't explain</a> if all will be executed or it will stop:</p>
  
  <blockquote>
    <p>The race function returns a Promise that is settled the same way as the first passed promise to settle. It resolves or rejects, whichever happens first.</p>
  </blockquote>
  
  <p><strong>UPD:</strong></p>
  
  <p>Sorry, didn't explained it correct. I do need to execute all promises in an array but not the way <code>Promise.all</code> does it. Yes, <code>Promise.all</code> executes all, but it waits until all of them executed, collecting their results and then returns one array with all their results in it. And I need to call a cirtain callback every time one of those 10 is fullfilled. That is without waithig all of them to be collescted by <code>Promise.all</code>.</p>