Event Loop & Timers

Throttle with Leading and Trailing Flags

hardJS SpecificJS / TS3 tests

Problem Statement

Implement `throttleWithOptions(fn, wait, { leading = true, trailing = true })` that invokes `fn` at most once per `wait` milliseconds, with configurable leading and trailing edge execution.

Examples

Example 1:
const throttled = throttleWithOptions(onScroll, 200, { leading: true, trailing: false });
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.