title: javascript settimeout never fires function and crashes chrome
body: <p>This code crashes chrome:</p>
  
  <pre><code> var ms = 1000;
  
   function wait(ms) {
  
       function _done() {
           done = true;
           alert('timer: ' + timer + ', done: ' + done);
           clearTimeout(timer);
       }
  
       var done = false;
       var timer;
       alert('starting timer');
       while (!done) {
           timer = setTimeout(_done, ms);
       }
       alert('wait done');
   }
  </code></pre>
  
  <p>Why? How do I get this right?</p>