//Create debounce function //Function will be called only first certain period of time //Every single call of this function will be delayed const saveInput =(name)=>{ console.log('saveinput ',name); } const debounce = (fn,timeout = 3000)=>{ let timer ; return (...args) =>{ console.log('inner function ',args); clearTimeout(timer); timer =setTimeout(()=>{ fn.apply(this,args); },timeout) } } const processChange = debounce(saveInput,2000); processChange("foo"); processChange("foo"); processChange("foo"); processChange("foo"); processChange("foo");