javascript的一道题,求大佬讲解?
有人能解释一下具体原因吗?不是太明白,尤其是settimeout的事件机制#前端#Promise.resolve().then(() => console.log(2)); new Promise((resolve, reject) => { resolve(); console.log(3); }).then(() => console.log(4)); setTimeout(() => { Promise.resolve().then(() => console.log(5)); setTimeout(() => console.log(7), 0); }, 0); setTimeout(() => console.log(6), 0);
结果顺序是:3 2 4 6 5 7