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

Classes in the new ES6 standard

Class is a new feature introduced into the new ECMAScript 2015 standard, also known as ES6. I thought it was just a move for the JavaScript to adapt to the Object-oriented world. It may be so, howeve

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