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

Expression vs. Statement

There are a lot of explanations online for distinguishing those two concepts. As in the answers of this question says, Expressions only contain identifiers, literals and operators, where operators i

Create a 2-dimensional Array in JavaScript

When I tried to create a two-dimensional array today, I surprisingly discovered that there is no built-in function which can help us to create two-dimensional array in JavaScript. I searched online an