Skip to content

Instantly share code, notes, and snippets.

@farishan
Created August 19, 2023 05:06
Show Gist options
  • Select an option

  • Save farishan/57e3594dfd5e869a268c15292c7f1fa0 to your computer and use it in GitHub Desktop.

Select an option

Save farishan/57e3594dfd5e869a268c15292c7f1fa0 to your computer and use it in GitHub Desktop.

Revisions

  1. farishan created this gist Aug 19, 2023.
    9 changes: 9 additions & 0 deletions debounce.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    function debounce(func, timeout = 300) {
    let timer;
    return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => {
    func.apply(this, args);
    }, timeout);
    };
    }