doSomething();
doSomethingElse();
doSomethingUsefulThisTime();
doSomething();
doSomethingElse();
doSomethingUsefulThisTime();
function some_3secs_function(value, callback){
//do stuff
callback();
}
some_3secs_function(some_value, function() {
some_5secs_function(other_value, function() {
some_8secs_function(third_value, function() {
//All three functions have completed, in order.
});
});
});
setTimeout(doSomething, 10);
setTimeout(doSomethingElse, 10);
setTimeout(doSomethingUsefulThisTime, 10);
function executeAsynchronously(functions, timeout) {
for(var i = 0; i < functions.length; i++) {
setTimeout(functions[i], timeout);
}
}
executeAsynchronously(
[doSomething, doSomethingElse, doSomethingUsefulThisTime], 10);