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 then() with two handlers: on fulfill, run the callback via Promise.resolve then return the original value; on reject, run the callback then re-throw. This ensures the callback always executes while the original result or error passes through unchanged.
Wrapping the callback in Promise.resolve handles both sync and async callbacks, while returning the original value or re-throwing preserves the promise chain semantics.
Updated Feb 2026