JavaScript · Middle · Question 15 of 75
How does debounce differ from throttle?
- ✓Correct answer: Debounce waits for a pause in events, throttle calls at most once per period
- 2Throttle waits for a pause in events, while debounce calls at most once per period
- 3They're synonyms that differ only by name in different libraries
Explanation
Debounce suits search-as-you-type: the request goes out when the user stops typing. Throttle suits scroll and resize: the handler runs regularly but at a limited rate. Both are implemented via a closure with a timer.