JavaScript
/Advanced
Promise Polyfill / Mock
Definition
One of the hardest interview questions: Implement the core functionality of a Promise from scratch. It requires deep understanding of the Event Loop, Callbacks, and State Machines.
Explain Like I'm New
The interviewer wants to see if you understand that a Promise is just an object with a state (pending, fulfilled, rejected), a value, and an array of callbacks (`.then`) that are triggered asynchronously when the state changes.
Real World Example
Writing a custom `MyPromise` class with `resolve`, `reject`, and `then` methods.
Common Use Cases
- •Senior Staff Engineering Interviews
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What are the three states of a Promise?
intermediate
- Why do you need an array to store `.then` callbacks instead of just a single variable?
advanced
- Write a simplified implementation of a Promise.