Skip to content

Instantly share code, notes, and snippets.

@theaungmyatmoe
Last active October 9, 2021 18:55
Show Gist options
  • Save theaungmyatmoe/9da475ee4b52080ecb4dcbb4e45beb80 to your computer and use it in GitHub Desktop.
Save theaungmyatmoe/9da475ee4b52080ecb4dcbb4e45beb80 to your computer and use it in GitHub Desktop.
Denouncing in JavaScript
const debounce = (callback, wait = 1000) => {
let timeoutId = null;
return function(...args) {
clearTimeout(timeoutId);
const next = () => callback.apply(this, args);
timeoutId = setTimeout(next, wait)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment