Skip to content

Instantly share code, notes, and snippets.

@kartikag01
Created July 24, 2019 04:24
Show Gist options
  • Save kartikag01/0b19bffab78c44d8cb3d47d2e67635d1 to your computer and use it in GitHub Desktop.
Save kartikag01/0b19bffab78c44d8cb3d47d2e67635d1 to your computer and use it in GitHub Desktop.
debounce function in java script
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