Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript debounce

function debounce(func, timeout = 300){
  let timer;
  return function(...args) {
    if (timer) {
      clearTimeout(timer);
    }
    
    timer = setTimeout(() => {
      func.apply(this, args);
    }, timeout);
  };
}
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #javascript #debounce
ADD COMMENT
Topic
Name
1+1 =