Debouncing and Throttling Explained Through Examples

Debounce

Debouncing and Throttling Explained Through Examples

在某些情境下,事件的觸發是需要被管制的,在 JavaScript 有兩種管制的模式,debounce 和 throttle,兩者略有差異。Debounce 會把數個相近的觸發歸併為單個觸發,是點擊事件被群組化的概念,Throttle 則是規定在幾毫秒內某個函式只會被執行一次,是管制函式執行的頻率的概念,連結的文章內也有兩者應用的示例,值得一讀。