title: What is the difference between "event loop queue" and "job queue"?
body: <p>I can not understand how the following code run. Why &quot;1&quot; is after &quot;b&quot; but &quot;h&quot; is after &quot;3&quot;? Should'n the order be: a, b, 1, 2, h, 3? Some articles said that the difference between &quot;event loop queue&quot; and &quot;job queue&quot; leads to the following output. But how? I have read the specification of <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-jobs-and-job-queues" rel="noreferrer">ECMAScript 2015 - 8.4 Jobs and Job Queues</a>, wanting to know how Promise'job works, but it makes me more confused. Can someone help me? Thank you!</p>
  <pre><code>var promise = new Promise(function(resolve, reject) {resolve(1)});
  promise.then(function(resolve) {console.log(1)});
  console.log('a');
  promise.then(function(resolve) {console.log(2);});
  setTimeout(function() {console.log('h')}, 0);
  promise.then(function(resolve) {console.log(3)});
  console.log('b');
  
  // a
  // b
  // 1
  // 2
  // 3
  // h
  </code></pre>
  <p>I know Promise is asynchronous, but the callback of setTimeout(..) asynchronous operation is always after Promise's asynchronous operation. Why?</p>