title: javascript debounce: how to get e.target?
body: <p>I'm using the implementation of debounce from <a href="https://davidwalsh.name/javascript-debounce-function" rel="nofollow noreferrer">https://davidwalsh.name/javascript-debounce-function</a>.</p>
  
  <p>The question now is: How do I get the event (e.target) from the eventlistener and use it inside the debounced function?</p>
  
  <p>This is what I've come up with:</p>
  
  <pre><code>document.querySelector('textarea')
    .addEventListener('input', (e) =&gt; {
       debounce(
           () =&gt; { console.log('debounce at '+e.target.value); },
           1000,
           false
       )(e); // add (e) so that the function debounce returns gets called inside the anonymous function
    });
  </code></pre>
  
  <p>The problem is that it triggers immediately (and the debounce effect gets effectively killed).</p>