DeepFrontend
Practice ArenaBlogSign in
Go Pro
DeepFrontend

Interview-grade learning paths and hands-on practice for mid-to-senior engineers. Master internals, patterns, and system architecture with runnable code.

All systems operational

Core Courses

  • -JavaScript Internals
  • -React Reconciliation
  • -TypeScript rigor
  • -Next.js Caching
  • -Node.js Event Loop
  • -System Design
  • -Web Security
  • -CSS & Page Layouts

Explore

  • Learning Paths
  • Practice Arena
  • Pricing Options
  • HTML Sitemap

Resources

  • Privacy Policy
  • Terms of Service
  • Email Support

© 2026 DeepFrontend. All rights reserved.

Expert learning environments for web engineering teams.

← All challenges
core15 min

Implement debounce

Implement debounce(fn, delay)

One of the most common practical interview questions — and one you'll actually reach for in real UI code (search-as-you-type, resize handlers).

Write a function debounce(fn, delay) that returns a new function. Calling the returned function repeatedly should only invoke fn once, after delay milliseconds have passed since the last call — every call before that resets the timer.

const search = debounce((query) => console.log("searching:", query), 300);
search("h");
search("he");
search("hel"); // only THIS call actually fires, 300ms after it happens

Requirements:

  • The returned function should forward its arguments to fn.
  • Calling it again before delay has elapsed should reset the wait — not queue a second call.

Run your code to see results.

Stuck? This challenge exercises:

javascript.closuresjavascript.event-loop