//Create throttle function //Function will be executed immediately const saveInput =(name)=>{ console.log('saveinput ',name); } const throttle = (fn,timeout = 3000)=>{ let isWaiting = false; return (...args) =>{ console.log('inner function ',args); if(!isWaiting){ fn.apply(this,args); isWaiting = true; setTimeout(()=>{ isWaiting = false; },timeout) } } } const processChange = throttle(saveInput,2000); processChange("foo0"); setTimeout(()=>{ processChange("foo1000"); },1000); setTimeout(()=>{ processChange("foo1200"); },1200); setTimeout(()=>{ processChange("foo2400"); },2400);