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

Extra white space on my page

I recently created a new site, collecting some useful cheatsheets. But on the page regarding to topic of Markdown, a funny thing happened without giving me any clue of why. There was some empty space

About eval in Shell

The textbook says in bash scripting, eval plays a role that the expression comes after will be evaluated twice before the final execution. By saying evaluation, it means the variables begining with $

TCP 3-way Handshake

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) both work in the transportation layer. TCP is a connection-oriented protocol, while UDP is considered as a connectionless protocol

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