frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

6 - Debounce

Open jsartisan opened this issue 1 year ago • 0 comments

index.js

export function debounce(func, delay) {
  let timerId;

  return function() {
    const context = this;
    const args = arguments;

    clearTimeout(timerId);
    timerId = setTimeout(function() {
      func.apply(context, args);
    }, delay);
  };
}

jsartisan avatar Feb 01 '24 04:02 jsartisan