title: Underscore Debounce Calling Multiple Times
body: <p>Calling <code>_.debounce()</code> causes the function to be executed multiple times instead of one time after they delay. How can I get the function within <code>_.debounce()</code> to be executed once after the specified delay? My use case is to perform an AJAX request after the user has stopped typing.</p>
  
  <p>For example, typing into the input will cause a message to appear in the console after 1 second. In my example, you will see multiple messages appear (one for each letter you type). How would I modify my code to see only one message?</p>
  
  <p><a href="https://plnkr.co/edit/3dGm55ZFqWe4V59HLgoC" rel="noreferrer">https://plnkr.co/edit/3dGm55ZFqWe4V59HLgoC</a></p>
  
  <pre><code>function onKeyUp() {
      _.debounce(() =&gt; {
          console.log('foo');
      }, 1000)();
  }
  &lt;input onkeyup="onKeyUp()" /&gt;
  </code></pre>