title: How the code after then runs if the Promise haven't been settled yet?
body: <p>When we chain a <strong>Promise's</strong> using chain, and the Promise is returned by <strong>then</strong>, so how code that isn't part of the <strong>then</strong> chain runs before the all chain was finished? How does the code jump over <strong>then</strong> calls? Shouldn't all then calls performed before running the &quot;console.log&quot; line of code?</p>
  <p>Here is the code:</p>
  <pre><code>Promise.resolve('333')
      .then((res)=&gt;{console.log(res);return new Promise((resolve,reject)=&gt; {setTimeout(function(){console.log('Timeout');resolve(1);},10000);console.log('Something');})})
      .then((res)=&gt;{console.log(res);return new Promise((resolve,reject)=&gt; {console.log('Something');resolve(2);})})    
      .then((res)=&gt;{console.log(res);return new Promise((resolve,reject)=&gt; {console.log('Something');resolve(3);})})
      .then((res)=&gt;{console.log(res);return new Promise((resolve,reject)=&gt; {console.log('Something');resolve(4);})})
  
  console.log(&quot;When?&quot;)
  </code></pre>
  <p>In the output &quot;When?&quot; is being printed first.. Now i can't understand how is it possible since the callback in the first  then will run only in about 10 seconds and only after that, the callback will return a Promise that will run the second <strong>then</strong>?
  Maybe i don't understand how the callback of <strong>then</strong> &quot;goes with&quot; the then function.
  I thought that <strong>then</strong> implementation looks a little bit like:</p>
  <pre><code>then(callback){
   let value= callback();
   if(value is promise){
       return value;
   }
  
   return Promise.resolve(value)
  }
  </code></pre>