Build a Custom Promise Implementation from Scratch

Implement a fully functional Promise class from scratch in JavaScript without using the native Promise. It should support the three states (pending, fulfilled, rejected), implement .then(), .catch(), and .resolve()/.reject() methods, handle chaining with proper microtask-like queuing, and support asynchronous resolution. This exercise deeply tests your understanding of the event loop, callback queuing, and how JS runtimes actually execute async code.

Examples
Input: []
Output:
Hints

Build a Custom Promise Implementation from Scratch

Implement a fully functional Promise class from scratch in JavaScript without using the native Promise. It should support the three states (pending, fulfilled, rejected), implement .then(), .catch(), and .resolve()/.reject() methods, handle chaining with proper microtask-like queuing, and support asynchronous resolution. This exercise deeply tests your understanding of the event loop, callback queuing, and how JS runtimes actually execute async code.