Sweaty Imposter

Throttle

TechniqueThroughput and FlowMidSeniorUpdated
Emit at most once per N ms regardless of how often it's called. Unlike debounce, never goes silent.

When to Use Throttle

Scroll handlers, mouse-move analytics, anything that fires constantly where you want a steady downsampled signal rather than 'wait for stop.'

In Practice

Scroll-based animations throttled to 60fps (16ms). Analytics 'on page heartbeat' fired at most every 5s. Rate-limiting outbound API calls.

How Throttle Comes Up in Interviews

Scenario

A scroll handler updates a sticky header position and is firing dozens of times per frame. You want a steady, downsampled signal, at most once per 16ms, never going silent while the user is actively scrolling. Which technique?

Throttle emits at most once per N ms regardless of how often the source fires, giving a steady stream. Debounce would suppress everything until the user paused, wrong shape for a live scroll.

Throttle emits at most one event per N ms regardless of how many fire, giving a steady downsampled signal, exactly what a scroll handler needs to keep a sticky header positioned without dropping frames. Lodash's _.throttle and the Underscore equivalent default to leading-edge (fire immediately, then suppress for N ms). Debounce would suppress everything until the user paused, which on a scroll handler means the header freezes mid-scroll, wrong UX. The throttle/debounce confusion is one of the most common front-end interview tells; the heuristic is 'do you want a periodic sample during the storm, or a single action at the end?'