.then(callback,… ,discardLast)

Description: Invoke callback methods inside or outside of timed loops.

callback – function(count…), …
one or more methods to be called. Each given method runs in the matching loop iteration.
All current iteration counts/events (from inner-most to outer-most loop) are passed as arguments.
discardLast – boolean, optional
whether to discard the last callback method after its usage or to call it again until the loop's end.
Defaults to false.

Tip: If you want to have a callback method called exactly once in a loop, use .then(callback,true).

Usage pattern