Created
August 13, 2025 08:12
-
-
Save gabri83/a62625c14a831c18b97ffa287b07d465 to your computer and use it in GitHub Desktop.
Debounce Function (JavaScript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debounce(fn, delay) { | |
| let timer; | |
| return function(...args) { | |
| clearTimeout(timer); | |
| timer = setTimeout(() => fn.apply(this, args), delay); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment