debounce
Anonymous
javascript
03/01/2021 5:37 PM
356 B
19
Indexable
const debounce = (callback, delay = 1000) => {
let timeoutId;
return (...arg) => {
if (timeoutId) {
clearTimeout(timeoutId)
}
timeoutId = setTimeout(() => {
callback.apply(null, arg);
}, delay);
}
}Editor is loading...