Repaso
Español
Frontend & WebIntermediateFE-08

Search-as-you-type should call the API only after the user pauses typing. Technique?

Options

  1. Throttle
  2. Debounce (Correct option)
  3. Memoization
  4. Polling

Answer

Debounce

Why

Debounce waits until events STOP for a set time (e.g. 300 ms) and then runs once. Typing 'python' fast triggers one search, not six.

Throttle runs at most once per interval while events keep coming, good for scroll or resize handlers.

Also cancel outdated requests with AbortController so an old, slow response cannot overwrite a newer one.

Remember

Debounce = run after the pause. Throttle = run at most every N ms.

Key terms

Practice this question in Repaso