Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptdebounce and throttleSingle-choice MCQ

A debounce is implemented to fire on the trailing edge. With this implementation, if `search()` is called at t=0ms, t=50ms, and t=120ms (delay 100ms), how many times does `fn` actually run, and when?

function debounce(fn, delay) { let timer; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); }; } const search = debounce(doSearch, 100);