resloves as soon as first promise rejects or resolves.
javascript
Scenario Questions
0-2 years experience
1How would you write a simple polyfill for Promise.race that works for an array of promises?
2What should your polyfill return if the input array is empty?
3If one of the items in the iterable isn’t a promise, how does your implementation handle it?
2-5 years experience
1We have a feature that races multiple API calls, but one call sometimes throws synchronously. How would you adjust your polyfill to propagate that error correctly?
2During debugging you notice your race polyfill never resolves when given a mix of native promises and custom thenables. What could be wrong?
3Explain the trade‑offs between using a for…of loop versus Array.prototype.some in your polyfill implementation.
5-8 years experience
1Our front‑end library must support IE11 and we want to replace native Promise.race with a polyfill across many modules. What performance considerations and edge‑case handling would you address?
2How would you design the polyfill to be safe when the iterable is a large, lazily‑generated stream of promises?
3If the environment provides a broken native Promise.race (e.g., it mishandles non‑iterable inputs), how would you detect and fallback to your polyfill without affecting other Promise methods?
8+ years experience
1We are planning a migration to a shared utility package that includes a Promise.race polyfill for all our micro‑frontends. What architectural guidelines would you set to ensure consistency, testing, and future deprecation when browsers catch up?
2How would you coordinate with other teams to replace direct uses of Promise.race with a wrapper that adds logging and timeout handling, while keeping backward compatibility?
3Discuss the long‑term maintenance implications of bundling a custom Promise.race polyfill versus relying on core‑js or similar libraries.
Follow-up Questions
What edge cases does your implementation need to consider?
How would you test it across different browsers and environments?
Can you explain how your polyfill matches the native Promise.race semantics?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.