title: How Job queue works with promise?
body: <p>I was learning promises in JS and got curious on how promises work with Job queues behind the scenes. To explain my confusion I want to show you this code:</p>
  
  <pre><code>new Promise(function(resolve, reject) {
  
    setTimeout(() =&gt; resolve(1), 1000);
  
  }).then(function(result) {
  
    alert(result); // 1
  
    return new Promise((resolve, reject) =&gt; { // (*)
      setTimeout(() =&gt; resolve(result * 2), 1000);
    });
  
  })
  </code></pre>
  
  <p>If you look at the above code, is it true that the callback of then() is put into Job queue beforehand and waits for promise to resolve? Or Is it true that callback of then() is pushed into job queue only after promise gets resolved?</p>