Created
January 5, 2021 05:57
-
-
Save Soontao/2f1e8de4b464d342ebf66b5c076fd728 to your computer and use it in GitHub Desktop.
debounce function
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
function debounce(func, wait) { | |
var timer; | |
return function () { | |
var context = this, args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(function () { | |
timer = null; | |
func.apply(context, args); | |
}, wait); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment