Skip to content

Instantly share code, notes, and snippets.

@superburrito superburrito/debounce.js
Last active Sep 2, 2019

Embed
What would you like to do?
function debounce(func, wait) {
let timeoutId;
return (...args) => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
func(...args);
}, wait);
}
}
@degamer106

This comment has been minimized.

Copy link

degamer106 commented Sep 2, 2019

https://medium.com/@griffinmichl/implementing-debounce-in-javascript-eab51a12311e

Is it a better idea to use a function declaraton on line 3 in case you have to debounce an object's method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.