const debounce = (callback, time) => {
let debounceTimer;
return (e) => {
window.clearTimeout(debounceTimer);
debounceTimer = window.setTimeout(callback.bind(null, e), time);
};
};
function handleInput(e) {
console.log(e.target.value);
}
document
.querySelector('#input')
.addEventListener('input', debounce(handleInput, 1000));