The function of this.constructor! = = Promises in promise source code

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

Apr.20,2022

looks at the safeThen method. The constructor of this.constructor should be the same as the Promsie constructor, receiving a method and passing in the resolve,reject parameter.
so this.constructor! = = Promises is to judge, this. Whether constructor inherits Promsie.


is used to handle situations when other objects refer to Promise's then method through call and apply?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4dadc-44f6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4dadc-44f6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?