67. create your own Promise

Is this helpful ?

from all members: - accepted / - tried

Promise is widely used nowadays, hard to think how we handled Callback Hell in the old times.

Can you implement a MyPromise Class by yourself?

At least it should match following requirements

  1. new promise: new MyPromise((resolve, reject) => {})
  2. chaining : MyPromise.prototype.then() then handlers should be called asynchronously
  3. rejection handler: MyPromise.prototype.catch()
  4. static methods: MyPromise.resolve(), MyPromise.reject().

This is a challenging problem. Recommend you read about Promise thoroughly first.

Let's try to solve this problem within 30 mintues.