Skip to content

Instantly share code, notes, and snippets.

@renews
Created October 8, 2023 07:47
Show Gist options
  • Save renews/8bd0e66a5fb908c31c3be47d8f79d867 to your computer and use it in GitHub Desktop.
Save renews/8bd0e66a5fb908c31c3be47d8f79d867 to your computer and use it in GitHub Desktop.
Debouce Function
function debounce(fn, delay) {
let timeoutId;
return (...args) => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => fn(...args), delay);
};
}
to call it
const debouncedFunction = debounce(functionToDebounce, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment