title: Javascript debouncing and throttling on Window resize
body: <p>Currently I have a handler on the Window object that listens to the resize event:</p>
  
  <pre><code>window.onresize = function(){
     doSomething(); 
  }
  </code></pre>
  
  <p>And I'm now trying to write two methods. The first one should only allow the doSomething() to be called once every second and no more frequent than that, the second one should only allow it to be called when doSomething() hasn't been called for one second. </p>
  
  <p>Can anyone provide me with a relatively easy implementation in plain JavaScript? </p>
  
  <p>I understand that throttling is about limiting the rate a function can fire in a certain time interval, and debouncing is about ensuring that a function not be called again until a certain amount of time has passed without it being called.</p>
  
  <p>Any help is appreciated. Thanks. </p>