question/promise-then-callbacks #48
Replies: 1 comment
-
答案是 6,知识点 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
也就是说 onFulfilled 必须是个函数否则就用 x => x 来替代 Promise.resolve(1) // 1
.then(() => 2) // 2
.then(3) // 替换成 x=>x // 2
.then((value) => value * 3) // 6
.then(Promise.resolve(4)) // 替换成 x => x // 6
.then(console.log) // 6 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
question/promise-then-callbacks
北美前端面试攻略
https://us-fe.github.io/question/promise-then-callbacks.html
Beta Was this translation helpful? Give feedback.
All reactions