Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js debouncing

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: #js #debouncing
ADD COMMENT
Topic
Name
1+8 =