Skip to content

Instantly share code, notes, and snippets.

View wteja's full-sized avatar

Weerayut Teja wteja

View GitHub Profile
@wteja
wteja / debounce.js
Created March 10, 2022 03:45
JavaScript Debounce Function
function debounce(callback, timeout = 500) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
callback.apply(callback, args);
}, timeout);
};
}