题目描述求解这段代码的输出顺序:console.log('begin');setTimeout(()=>{console.log('setTimeout1');Promise.resolve().then(()=>{console.log('promise1');setTimeout(()=>{console.log('setTimeout2');});}).then(()=>{console.log('promise2');});newPromise(resolve=>{console.log('a');resolve();}).then(()=>{console.log('b');});},0);console.log('end');实际输出顺序为:beginendsetTimeout1apromise1bpromise2setTimeout2谁能解释一下为什么是这个顺序呢?万分感谢
牛魔王的故事
相关分类