title: How can I wait for set of asynchronous callback functions?
body: <p>I have code that looks something like this in javascript:</p>
  
  <pre><code>forloop {
      //async call, returns an array to its callback
  }
  </code></pre>
  
  <p>After ALL of those async calls are done, I want to calculate the min over all of the arrays.</p>
  
  <p>How can I wait for all of them?</p>
  
  <p>My only idea right now is to have an array of booleans called done, and set done[i] to true in the ith callback function, then say while(not all are done) {}</p>
  
  <p>edit: I suppose one possible, but ugly solution, would be to edit the done array in each callback, then call a method if all other done are set from each callback, thus the last callback to complete will call the continuing method.</p>
  
  <p>Thanks in advance.</p>