Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Debounce from Scratch
const debounce = (callback, wait) => {
let timeout = null;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => {
callback.apply(this, args);
}, wait);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment