Code
JavaScript
function debounce(func, delay) { let timer; return function (...args) { clearTimeout(timer); timer = setTimeout(() => func.apply(this, args), delay); }; }
// Example usage:
const fetchData = () => { console.log("Fetching data..."); };
const debouncedFetch = debounce(fetchData, 1000);
document.getElementById("search").addEventListener("input", debouncedFetch);
Plain Text
inline code Bold, Italicize, Underline, Link, code , break, s p a c i ng,$F = G * (m₁ * m₂) / r²$Notion as a CMS