Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Implement a simplified Promise class with pending/fulfilled/rejected states and a handlers queue. The constructor runs the executor synchronously, calling resolve or reject to transition state. The then method returns a new MyPromise, queuing handlers if still pending or scheduling them asynchronously if already settled.
State machine semantics ensure a promise transitions only once, and deferred handler execution via the queue guarantees then callbacks registered before settlement are invoked when the value becomes available.
Updated Feb 2026