Extend Javascript promise and resolve or reject it inside constructor
问题 I want to extend native Javascript Promise class with ES6 syntax, and be able to call some asynchronous function inside the subclass constructor. Based on async function result the promise must be either rejected or resolved. However, two strange things happen when then function is called: subclass constructor is executed twice "Uncaught TypeError: Promise resolve or reject function is not callable" error is thrown class MyPromise extends Promise { constructor(name) { super((resolve, reject)