【Promise第六题】
参考答案
要点
new Promise(executor)的 executor 同步执行,抛错直接 reject;resolve/reject只第一次生效;then的返回值决定后续状态:普通值 fulfilled、throw/rejected 走 catch;- 未 catch 的 rejection 触发全局 unhandledrejection。
按上述规则逐行推演即可得到输出顺序。
【Promise第六题】
new Promise(executor) 的 executor 同步执行,抛错直接 reject;resolve/reject 只第一次生效;then 的返回值决定后续状态:普通值 fulfilled、throw/rejected 走 catch;按上述规则逐行推演即可得到输出顺序。
本题来自 计算机知识面试题库,共 921 道题。