Skip to content

Instantly share code, notes, and snippets.

@jyotiarora2610
Created July 1, 2019 15:51
Show Gist options
  • Save jyotiarora2610/ca53ec94fd02e3f7128c3bebd02f3461 to your computer and use it in GitHub Desktop.
Save jyotiarora2610/ca53ec94fd02e3f7128c3bebd02f3461 to your computer and use it in GitHub Desktop.
function throttle(func, wait) {
let flag = true;
return function() {
let context = this;
let args = arguments;
if (flag) {
func.apply(this, args);
flag = false;
}
else {
setTimeout(() => {
flag = true
}, wait);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment