Skip to content

Instantly share code, notes, and snippets.

@tcase360
Last active April 20, 2020 20:37
Show Gist options
  • Save tcase360/3d0e370eca06189f025670d7dd40fe30 to your computer and use it in GitHub Desktop.
Save tcase360/3d0e370eca06189f025670d7dd40fe30 to your computer and use it in GitHub Desktop.
Debounce function in ES6
const debounce = (fn, time) => {
let timeout;
return function() {
const functionCall = () => fn.apply(this, arguments);
clearTimeout(timeout);
timeout = setTimeout(functionCall, time);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment