Polyfills and JavaScript Utility Implementation Questions

Rebuilding standard JavaScript behavior and common utility libraries from scratch, the machine-coding interview genre where a candidate re-creates a familiar API to prove they understand its mechanics. Covers a minimal Promise built from first principles (chaining, asynchronous handlers, single settlement, thenable adoption, error flow) and Promise.allSettled-style combinators; polyfills for browser APIs such as IntersectionObserver, and a keyed virtual DOM diff; utilities such as debounce (leading and trailing, cancel, flush), throttle, and React hooks that debounce a value or a callback with stable identity and no stale closures; deep clone (cycles, shared references, Dates, RegExps), shallow and deep equality (typed arrays, Maps and Sets, NaN and -0), nested object helpers (safe path get, flatten and unflatten, deep merge), curry with placeholders and partial application, and memoize with cache keys and WeakMap-based caches; and small infrastructure such as event emitters (on, off, once, emit, context binding, listener leaks). Emphasizes edge cases, correct this binding, argument handling, spec fidelity, and complexity. Using these built-ins as a language feature, the event loop and async/await semantics, DOM traversal and event propagation, functional programming as a paradigm, and generic algorithm puzzles are covered elsewhere.

HardTechnical
48 practiced

Implement curry(fn) so the returned function accepts arguments across several calls until the original arity is satisfied. Extend it so callers can leave a gap in the argument list and fill it in later, and make sure this is preserved if the final call is a method call.

MediumTechnical
51 practiced

Write your own version of Promise.allSettled for an environment that lacks it. It accepts an iterable of promises or plain values and resolves with one outcome per input in input order. Say how you would treat an empty input.

HardTechnical
50 practiced

Implement a minimal virtual DOM diff in vanilla JavaScript. Given two simplified virtual trees whose children may carry keys, produce the list of DOM operations needed to update the real DOM, minimizing moves in reordered lists. Text nodes are plain strings.

MediumTechnical
56 practiced

Implement mergeDeep(target, source) for nested plain objects where arrays in the source replace those in the target. Source must not be mutated. Discuss the edge cases and how the array policy would change if the business rule were to combine arrays instead.

MediumTechnical
54 practiced

Write a React hook in TypeScript that returns a debounced copy of a value. It should work for any value type, optionally return the first value immediately, avoid updating state after unmount, avoid recreating timers needlessly, and let the caller force a pending value through right away. Walk through the edge cases.

Unlock Full Question Bank

Get access to all 21 Polyfills and JavaScript Utility Implementation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.