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.

MediumTechnical
50 practiced

Implement memoize for a pure function that takes primitive arguments, using a closure for the cache. Then extend it so it can cache calls that take objects without keeping those objects alive forever, and discuss the downsides of a cache that never evicts.

MediumTechnical
79 practiced

Implement deepClone in JavaScript that survives self-referencing data and keeps the shared structure intact in the copy. Handle plain objects, arrays, Dates and RegExps. Explain the algorithm and its time and space complexity.

HardTechnical
46 practiced

Implement an EventEmitter class in JavaScript that lets callers subscribe, subscribe for a single call, unsubscribe and publish. Listeners may be registered with an optional context to use as this, and removal must target exactly the right registration. Explain how you store listener metadata and how you would stop leaks when components forget to unsubscribe.

That is every published Polyfills and JavaScript Utility Implementation question for Software Engineer so far. Browse the other topics in this category, or practice this one interactively.