title: Join multiple callbacks/threads in javascript?
body: <p>I'm looking for a Thread.Join() type thing. Lets say I trigger 4 events in javascript. I want to execute code but only after all 4 callbacks have been completed. How do I do that? The only way I can think of is checking if any the 4 callbacks are in process via global var in which case i ignore or throw exception. But otherwise do something like globalVar++ in each callback and call IsItDone() at the end of each callback which checks if the globalVar is == 4.</p>
  
  <p>But.. I kind of dont like it especially since I need to use a global var.</p>