const debounce = (fn, ms = 300) => {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, args);
}, ms);
};
}
const inputbox = document.querySelector(".input");
const checkForEmpty = ({ value: v }) => v === "" && console.log("Empty");
const processChanges = debounce(() => checkForEmpty(inputbox), 500);
inputbox.addEventListener("input", processChanges);