Iterations in JavaScript Promise

Imagine we have an async task below that needs to be done for several times in sequence. 12345678function asyncJob() { for (var i = 0 ; i < 4;) { console.log(i++); setTi

A simple timeout mechanism for Promise

Sometimes we need to do some asynchronous jobs which may last for a while, like submitting an Ajax POST request. And if there is problem with connection, we may not get response in time as expected.

Rejection in Promise

I am always curious that if a Promise is rejected at any position, will the following then() still be executed? Consider the following codes as an example: 1234567891011121314151617181920212223Promis