Implement robust debounce and throttle in JavaScript

Quick Overview

This question evaluates a developer's ability to implement debounce and throttle utilities in JavaScript, testing competencies in asynchronous timing, timer management, cancellation/flush semantics, error propagation, and handling edge cases such as rapid bursts, timer drift, and re-entrancy.

Implement robust debounce and throttle in JavaScript

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement debounce(fn, wait, options) and throttle(fn, wait, options) in JavaScript. Support leading/trailing invocation toggles, maxWait for throttle, cancellation, and immediate flush. Ensure correctness with edge cases such as rapid bursts, timer drift, re-entrancy, and error propagation. Analyze time/space complexity and propose tests.

Quick Answer: This question evaluates a developer's ability to implement debounce and throttle utilities in JavaScript, testing competencies in asynchronous timing, timer management, cancellation/flush semantics, error propagation, and handling edge cases such as rapid bursts, timer drift, and re-entrancy.

|Home/Coding & Algorithms/Amazon
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
5
0

Implement debounce(fn, wait, options) and throttle(fn, wait, options) in JavaScript. Support leading/trailing invocation toggles, maxWait for throttle, cancellation, and immediate flush. Ensure correctness with edge cases such as rapid bursts, timer drift, re-entrancy, and error propagation. Analyze time/space complexity and propose tests.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...