title: Avoid using await in a for loop when Promise result updates the iterating loop variable itself
body: <p>Is there any way to not use await inside loop for following code?</p>
  <pre><code>const redirects = ['redirectId1'];
  
  for (let i = 0; i &lt; redirects.length; i++) {
    const promiseResult = await anAsyncFunction(redirects[i]);
    
    if (promiseResult.redirects) {
      redirects.forEach(newRedirect =&gt; {
        if (!redirects.includes(newRedirect)) redirects.push(newRedirect);
      });
    }
  }
  
  </code></pre>
  <p>I've tried using Map</p>
  <pre><code>const redirects = ['redirectId1'];
  
  const promiseArr = redirects.map(async redirect =&gt; {
    const promiseResult = await anAsyncFunction(redirect);
  
    if (promiseResult.redirects) {
      redirects.forEach(newRedirect =&gt; {
        if (!redirects.includes(newRedirect)) redirects.push(newRedirect);
      });
    }
  });
  
  await Promise.all(promiseArr);
  </code></pre>
  <p>but in doing so, code executes further before <code>newRedirect</code> is pushed to redirects array
  thus not calling <code>anAsyncFunction</code> for new added value.</p>
  <p>I want to know if there any possible way to achieve this?</p>