Debouncing waits for a pause in events before acting. Throttling limits how often an action can occur.
// Debounce: wait 300ms after last keystroke
let timeout;
input.oninput = () => {
clearTimeout(timeout);
timeout = setTimeout(search, 300);
};
Use debouncing for search inputs. Use throttling for scroll handlers.