Debounce

Creates a debounced function that delays invoking the provided function until after the specified delay.

CategoryFunctions
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    const debouncedFunc = debounce(() => console.log('Hello'), 1000);

    Output:

    Logs 'Hello' after a 1-second delay.

Return

Returns a new debounced function.

Type: function

Props

NameTypeDefaultRequiredDescription
fnfunctionnullYesThe function to debounce.
delaynumbernullYesThe number of milliseconds to delay.

Notes

The returned function will delay the invocation of `fn` until after the specified `delay` period.

Tags

  • debounce
  • delay
  • function

Related