title: Underscore _.debounce() : How to execute method only the last time received?
body: <p><code>_.debounce()</code> fires at most evevry x milliseconds with <code>_.debounce(function,x</code>) .. I want to adapt this to only execute a method <code>x</code> millis after the <strong>last</strong> <code>_.debounce()</code>. </p>
  
  <p>How do I go about this? (I've read that <code>$.debounce</code> does exactly that btw.) </p>
  
  <p>I've tried to do this, but it isn't bullet-proof (not to mention butt-ugly) </p>
  
  <pre><code>var timeout;
  $(window).on("resize",_.debounce(function(){
    if(timeout){
      clearTimeout(timeout);
    }
    //when debounce comes in we cancel it.. this means only the latest debounce actually fires.
    //not bullet proof
    timeout = setTimeout(resizeMap,100);
  },50));
  </code></pre>
  
  <p>How to do this elegantly? </p>