Last active
October 9, 2021 18:55
-
-
Save theaungmyatmoe/9da475ee4b52080ecb4dcbb4e45beb80 to your computer and use it in GitHub Desktop.
Denouncing in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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