ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

Debounce vs throttle — what's the difference and when do you use each?

Quick answer

Debounce waits for activity to stop then runs once; throttle runs at most once per interval. Debounce → search input; throttle → scroll/resize.

In detail

Debounce collapses a burst of events into a single call after a quiet period — ideal for search-as-you-type. Throttle guarantees a steady maximum rate regardless of how often the event fires — ideal for scroll, mousemove and resize handlers. Both rely on closures holding timer state.

const debounced = debounce(onSearch, 400); // fires after typing stops
const throttled = throttle(onScroll, 200);  // fires every 200ms max

Why interviewers ask this: Asked at almost every front-end interview, conceptually and to code.

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →