frontend-challenges
frontend-challenges copied to clipboard
6 - Debounce
index.js
export function debounce(func, delay) {
let timerId;
return function() {
const context = this;
const args = arguments;
clearTimeout(timerId);
timerId = setTimeout(function() {
func.apply(context, args);
}, delay);
};
}