A deeper look at event loop (micro/macro tasks)

One common question So why the result is 1,2,3,5,4 rather than 1,2,3,4,5? If we look at the detail, looks like the async of setTimeout is different from the async of Promise.then, at least they are not in the same async queue. The answer is here in the whatwg SPEC. An event loop has one or more task queues.(task…