We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const promise1 = new Promise((resolve, reject) => { console.log("promise1"); resolve("resolve1"); }); const promise2 = promise1.then((res) => { console.log(res); }); console.log("1", promise1); console.log("2", promise2); // promise1 // 1, Promise{<resolved>, 'resolve1'} // 2, Promise{<pending>} // resolve1
Promise
promise1
resolve
resolved
promise1.then
promise2
pending
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Promise 题目 - 4
过程分析
Promise
, 执行改构造函数中的代码promise1
resolve
函数, 将promise1
的状态改变为resolved
, 并将结果保存下来promise1.then
这个微任务, 将它放入微任务队列promise2
是一个新的状态为pending
的Promise
promise1
的状态是resolved
promise2
的状态是pending
promise1.then
这个微任务且状态为resolved
, 执行它The text was updated successfully, but these errors were encountered: