Created
August 12, 2020 20:39
-
-
Save leolanese/6c967ec4efe4df9f0d62f3ed0a84652f to your computer and use it in GitHub Desktop.
debounce js
This file contains hidden or 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 = (fn, time) => { | |
let timerId; | |
return function(...args) { | |
const functionCall = () => fn.apply(this, args); | |
clearTimeout(timerId); | |
timerId = setTimeout(functionCall, time); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment