Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

debounce js

function debounce(fn, delay) {
  let timer;
  return (() => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(), delay);
  })();
  
};

// usage
function someFn() {
  console.log('Hi')
};

debounce(someFn, 1000);
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #debounce #js
ADD COMMENT
Topic
Name
2+8 =