Skip to content
RED SAG Skills
hard20 pts · first answer countsjavascriptclosurestimers

A debounce that never debounces

Typing "phone" fires five API calls instead of one. What is the bug?

function debounce(fn, ms) {
  return (...args) => {
    let timer
    clearTimeout(timer)
    timer = setTimeout(() => fn(...args), ms)
  }
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions