Phân Biệt Throttle Và Debounce

Chắc hẳn ai cũng gặp qua khái niệm này trong Functional Reactive Programming hoặc trong ứng dụng Javascript của mình. Có rất nhiều bài viết nói về sự khác biệt giữa 2 khái niệm này, nhưng có 1 cách dễ hiếu nhất mình thấy thật sự dễ nhớ, nên post lên, các bạn cần thì tham khảo qua

I. Throttle:
Throttling enforces a maximum number of times a function can be called over time. As in “execute this function at most once every 100 milliseconds.”
Thực thi số lần tối đa 1 chức năng có thể được gọi theo thời gian

II. Debounce:
Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in “execute this function only if 100 milliseconds have passed without it being called.”

Thực thi 1 chức năng sẽ không được gọi cho đến khi một khoảng thời gian trôi qua mà nó vẫn chưa được gọi

Nguồn: https://css-tricks.com/the-difference-between-throttling-and-debouncing/

Rate this post

You May Also Like

About the Author: truongluu

Leave a Reply

Your email address will not be published. Required fields are marked *