Create MyPromise class with constructor(executor), then, catch, and static resolve/reject. Handle chaining and thenables.
Skip to solutionKEEP THE
hardDSA
Implement a minimal Promise/A+ (MyPromise) with then/catch
733 views
01
Understand the problem
promisecustom-promisethenable
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
Approach: States pending/fulfilled/rejected; queue handlers; resolvePromise handles thenables recursively; then returns new promise.
class MyPromise {
constructor(executor) {
this.state = 'pending'; this.value = undefined; this.handlers = [];
const resolve = (v) => this._resolve(v);
Solution ready — 2 min read
Classified // press E to declassify
04
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 183 of 190 decoded in the JavaScript Coding track. One more won't hurt.