I am interested in the \"debouncing\" function in javascript, written here : http://davidwalsh.name/javascript-debounce-function
Unfortunately the code is not explai
Simple debounce function :-
HTML:-
Javascript:-
function debounce(fn, delay) {
let timeoutID;
return function(...args){
if(timeoutID) clearTimeout(timeoutID);
timeoutID = setTimeout(()=>{
fn(...args)
}, delay);
}
}
document.getElementById('myid').addEventListener('click', debounce(() => {
console.log('clicked');
},2000));