Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

debounce javascript

let timeout;  

const debounce = (callback, wait) => {
    return (...args) => {
      clearTimeout(timeout);
      timeout = setTimeout(function () {
        callback.apply(this, args);
      }, wait);
    };
  };

const exampleFn = () => {
  console.log('Hello Word')
};

debounce(exampleFn, 1000);
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #debounce #javascript
ADD COMMENT
Topic
Name
6+4 =