Created
April 23, 2020 06:56
-
-
Save anshuraj/6abdec99078f8a1eb6fa79731fc5534f to your computer and use it in GitHub Desktop.
Debouncing 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
const debounce = function (func, delay) { | |
let timer; | |
return function() { | |
const context = this; | |
const args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(() => func.apply(context, args), delay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment