Debounce and Throttle
Purpose
Debounce
const debounce = (callFn, time) => {
let timer = null;
return () => {
clearTimeout(timer);
timer = setTimeout(() => {
callFn();
}, time);
};
};
const test = debounce(() => {
console.log("test");
}, 1000);Throttle
Difference
Last updated
