Skip to content

Instantly share code, notes, and snippets.

@anshuraj
Created April 23, 2020 06:56
Show Gist options
  • Save anshuraj/6abdec99078f8a1eb6fa79731fc5534f to your computer and use it in GitHub Desktop.
Save anshuraj/6abdec99078f8a1eb6fa79731fc5534f to your computer and use it in GitHub Desktop.
Debouncing function
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