JavaScript Interview Question: Implement debounce
Task: write debounce(fn, wait) that returns a function which only calls fn after it stops being called for wait milliseconds. Typical use: search-as-you-type. Solution function debounce(fn, wait) { let timer; return function (...args) { clearTimeout(timer); //...