Build a JavaScript Promise from Scratch: How `then`, Chaining, and Microtasks Actually Work
Build a Promise from scratch in 60 lines. State machine (pending → fulfilled / rejected), why callbacks run as microtasks, how chaining works (then returns a new Promise that adopts the inner result’s state), catch/finally as sugar, and how async/await desugars to .then.









