我正在检查Promise构造函数的静态方法。当我控制日志记录Promise构造函数属性时,我看到了resolve和reject方法:
console.log(Object.getOwnPropertyNames(Promise))
// Array(7) [ "all", "race", "reject", "resolve", "prototype", "length", "name" ]
我想知道这些解决方法和拒绝方法是在执行程序中使用的相同方法作为其参数,或者这些是不同的东西:
const myFirstPromise = new Promise((resolve, reject) => {
// do something asynchronous which eventually calls either:
//
// resolve(someValue); // fulfilled
// or
// reject("failure reason"); // rejected
});
规范提到了Promise Resolve Functions和Promise.resolve(x),它是%Promise_resolve%内部对象。有人能告诉我这些是一样的吗?