Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

debouncing js

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