Prompt
Implement debounce(fn, wait, options):
- Trailing by default:
fnruns once,waitms after the last call { leading: true }:fnfires immediately on the first call, then ignores calls until quiet- The returned function exposes
.cancel()to drop any pending invocation - Arguments and
thisof the last call are forwarded tofn
This is the search-box / resize-handler primitive — write it like you'd ship it.
Hints
Solution
Your Code
15 min