Throttle
When to Use Throttle
In Practice
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?'