title: is setTimeout/clearTimeout expensive?
body: <p>I have something like the following:</p>
  
  <pre><code>var myTimeout;
  function delayStuffUntil( when ){ 
    if( myTimeout) clearTimeout( myTimeout );
    myTimeout = setTimeout( stuff, when - Date.now() );
  }
  </code></pre>
  
  <p><code>delayStuffUntil</code> is going to get called a good deal, and it's likely that it will get called with the same value of <code>when</code> several times in a row.</p>
  
  <p>Is <code>setTimeout</code>/<code>clearTimeout</code> expensive enough that I should bother checking the current <code>when</code> against my last value of <code>when</code> (and only change timers if different)?</p>
  
  <p>I thought about doing it, but the truth is that <code>when</code> is a bit more fiddly to compare, and I figured premature optimization is the root of all evil, so I might be making work when I didn't need to.</p>