Read the article from: Https://blog.coding.net/blog/the-difference-between-throttle-and-debounce-in-underscorejs
Usage Scenarios
These two functions can be taken into account as long as they are involved in a continuous event or frequency control-related application, such as:
- Game shooting, KeyDown events
- Text input, AutoComplete, KeyUp events
- Mouse movement, MouseMove events
- DOM element dynamic positioning, resize and scroll events for window objects
There's a metaphor in the article.
throttle
Strategy of the elevator. Ensure that if the elevator first person comes in, 15 seconds after delivery on time, do not wait. If there is no one, then standby.
debounce
Strategy of the elevator. If someone comes in the elevator, wait 15 seconds. If another person comes in, 15 seconds waits for a re-timer until 15 seconds expires and the shipment begins.
The commentary is also wonderful:
Throttle: Trigger-last action execution time greater than limit time, execute action, record execution time
Debounce: Trigger-record trigger time-last action trigger time greater than limit time-perform action
-----------
You can see it.
throttle
: Timed fixed point
Debounce: for deferred processing
Talking about the difference between _.throttle and _.debounce in underscore.js [turn]