When would you use debounce vs throttle in a real application?
Debounce for search input (300ms), auto-save (1000ms), form validation (500ms). Throttle for scroll (100ms), mousemove (50ms), rapid button clicks (500ms). Debounce after activity stops; throttle during activity.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Debounce vs Throttle Interview Questions (Walmart)
Debounce delays execution until activity stops (only the last call runs, after a delay). Throttle limits to once per interval (executes at a fixed rate, ignoring calls in between).
Debounce: function debounce(fn, delay) { let timer; return function(...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); }; }. Throttle: function throttle(fn, delay) { let last = 0; return function(...args) { const now = Date.now(); if (now - last >= delay) { last = now; fn.apply(this, args); } }; }.
Yes. A hybrid approach: throttle during activity (rate-limited) plus a trailing debounce call (ensures the last call runs). Some lodash implementations offer this as the default throttle behavior.
Still have questions?
Browse all our FAQs or reach out to our support team
