after reading the source code core.js of promise, I really don"t quite understand the this.constructor! = = Promises in the code.
Promise.prototype.then = function(onFulfilled, onRejected) {
if (this.constructor !== Promises) {
return safeThen(this, onFulfilled, onRejected);
}
var res = new Promises(noop);
handle(this, new Handler(onFulfilled, onRejected, res));
return res;
};
function safeThen(self, onFulfilled, onRejected) {
return new self.constructor(function (resolve, reject) {
var res = new Promises(noop);
res.then(resolve, reject);
handle(self, new Handler(onFulfilled, onRejected, res));
});
}
this.constructor !== Promises
this new promise can be read. Then this this must all be this instance
how can I execute the code in the safeThen function