title: How can await promise resolve if resolve(...) is inside setTimeout?
body: <p>What is the order of execution for code below?</p>
  <p>If await makes us wait for &quot;promise&quot; to resolve, but resolve(...) is inside a setTimeout, and a setTimeout only gets executed after the stack is empty... How are we not frozen on await? Are there not still things on the stack when we are &quot;await&quot;ing? Is there some exception to an await-y setTimeout , or am I not understanding the stack?</p>
  <pre><code>async function f() {
  
    let promise = new Promise((resolve, reject) =&gt; {
      setTimeout(() =&gt; resolve(&quot;done!&quot;), 1000)
    });
  
    let result = await promise; // wait until the promise resolves (*)
  
    alert(result); // &quot;done!&quot;
  }
  
  
  f();
  
  </code></pre>