title: Does setTimeout() run on a separate thread?
body: <p>Curious to see whether <code>setTimeout()</code> will be fired up asynchronously, I tried the following test script:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function timedText() {
    var x = document.getElementById("txt");
    setTimeout(function() {
      x.value = "1 second"
    }, 1000);
    setTimeout(function() {
      x.value = "2 seconds"
    }, 2000);
    setTimeout(function() {
      x.value = "3 seconds"
    }, 3000);
  
    while (true) {}
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;Click on the button below. The input field will tell you when two, four, and six seconds have passed.&lt;/p&gt;
  
  &lt;button onclick="timedText()"&gt;Display timed text&lt;/button&gt;
  &lt;input type="text" id="txt"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Sure enough, clicking the button causes the browser to <strong>hang</strong>.</p>
  
  <p>This tells me that <code>setTimeout()</code> does <strong>not</strong> run on a separate thread.</p>
  
  <p>But on a recent interview, the interviewer suggested otherwise... Does that mean that <code>setTimeout()</code> is browser/implementation dependent?</p>