Created
July 24, 2019 04:24
-
-
Save kartikag01/0b19bffab78c44d8cb3d47d2e67635d1 to your computer and use it in GitHub Desktop.
debounce function in java script
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) { | |
let timeout; | |
return function(...args) { | |
const context = this; | |
if (timeout) clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
timeout = null; | |
func.apply(context, args); | |
}, wait); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment