Skip to content

Instantly share code, notes, and snippets.

@kettanaito
Last active July 22, 2024 11:49
Show Gist options
  • Save kettanaito/9ae2fdda8e57b9b8fa314b9705b7aa5a to your computer and use it in GitHub Desktop.
Save kettanaito/9ae2fdda8e57b9b8fa314b9705b7aa5a to your computer and use it in GitHub Desktop.
Debounce vs Throttle: Throttle
function throttle(func, timeout) {
let wait = false;
return function (...args) {
if (!wait) {
func(...args)
wait = true;
setTimeout(function () {
wait = false;
}, timeout);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment