title: Does delaying the next iteration in the for loop clear the JavaScript call stack?
body: <p>I created a foreach loop which calls Facebook's API to fetch data. But since the number of calls are too high, it gives an error that JavaScript's maximum call stack size has exceeded and it stops there.
  I was thinking of delaying the execution of each iteration after 5 mins or a fix interval of time.
  I took help from <a href="https://stackoverflow.com/questions/30514584/delay-each-loop-iteration-in-node-js-async">this question</a>. Now I want to know, does executing each iteration after an interval of time clear the JavaScript call stack or not?</p>
  <p><strong>Code:</strong></p>
  <pre><code>var updateFeeds = function(){
          db.collection(&quot;accounts&quot;).find({&quot;status&quot;: &quot;live&quot;}).toArray(function(err, clients) {
          var interval = 10 * 1000;
          var i = 0;
          clients.forEach(function(client, index, array){
              setTimeout( function (i) {
                  i++;
                 ****code*****
  
              }, interval * i, i);
          });
  </code></pre>
  <p>For each client there are almost 5000 request calls inside the code. I want to clear the JavaScript heap memory after completion of each iteration.</p>
  <blockquote>
  <p>Error: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory</p>
  <p>Aborted (core dumped)</p>
  </blockquote>