Skip to main content

Practice ยท 1 of 2

Debounce vs Throttle Signatures

Write both, called with (fn, waitMs) and returning wrapped functions. For this exercise they run SYNCHRONOUSLY with a fake clock object { now() } passed as a third argument: debounce(fn, wait, clock) runs fn only after a gap of >= wait since the LAST call attempt (trailing edge); throttle(fn, wait, clock) runs fn immediately on the first call attempt, then blocks until wait has elapsed (leading edge).

Difficulty: advanced

Back to lesson: Practice: Timers & Observers โ€” Practice