title: nested setTimeout functions when subfunctions include varying delays
body: <p>I have a set of about 100 arguments that all take different amounts of time to run through a given function. Each is a brief animation on a page, animating a different part depending on the argument, and they take about 1-3 seconds each. </p>
  
  <p>I checked this: <a href="https://stackoverflow.com/questions/17574571/nested-settimeout-alternative">Nested setTimeout alternative?</a></p>
  
  <p>...but it only works when the subfunctions take the same amount of time, </p>
  
  <p>I can collect the arguments in an array in the order they should go, i.e.:</p>
  
  <p>args= [arg1, arg2, arg3, arg4...]</p>
  
  <p>Currently my calls looks like this:</p>
  
  <pre><code> setTimeout(myfunction(arg1), 3000);
   setTimeout(myfunction(arg2), 5000);
   setTimeout(myfunction(arg3), 7500);
   setTimeout(myfunction(arg4), 8500);...
  </code></pre>
  
  <p>I'd really like to be able to have code that says "when myfunction(arg1) is finished, wait 500 milliseconds and then execute myfunction(arg2), then when that is finished wait 500 ms and execute func3, etc." </p>
  
  <p>I don't know how to incorporate that into either the running of the setTimeouts or the definition of myfunction().</p>
  
  <p>Thank you.</p>