Last active
April 20, 2020 20:37
-
-
Save tcase360/3d0e370eca06189f025670d7dd40fe30 to your computer and use it in GitHub Desktop.
Debounce function in ES6
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 timeout; | |
return function() { | |
const functionCall = () => fn.apply(this, arguments); | |
clearTimeout(timeout); | |
timeout = setTimeout(functionCall, time); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment