title: setTimeout wait for setTimeout
body: <p>I stumbled upon a problem:
  the code is supposed to output "hi1" "hi2" "hi3" "hi4" in that order.
  I wrote this simplified code, the actual code is more complicated and causes me to not be able to remove some of the functions I marked.</p>
  
  <pre><code>function test() {
      console.log("hi2");
      setTimeout(function () { //maybe replace this?
      console.log("hi3");
      }, 2000);
  }
  
  console.log("hi1");
  test();
  setTimeout(function () { //cannot get rid of this
      console.log("hi4");
  }, 0);
  </code></pre>
  
  <p>how do I make it output in order?</p>