frontend-challenges
frontend-challenges copied to clipboard
6 - Debounce
index.js
export function debounce(func, delay) {
var canInvoke = true;
var callbackFn;
// your answer here
return (args)=>{
callbackFn = func.bind(this, args);
if(canInvoke){
canInvoke = false
setTimeout(()=>{
callbackFn()
canInvoke = true;
}, delay)
}
}
}