js promise settimeout 执行时间

代码:

console.log("start");
setTimeout(()=>{
    console.log("children2");
    Promise.resolve().then(()=>{
        console.log("children3");
    });
},0);
new Promise(function(resolve,reject){
    console.log("children4");
    setTimeout(function(){
        console.log("children5");
        resolve("children6");
    },0);
}).then((res)=>{
    console.log("children7");
    setTimeout(()=>{
        console.log(res);
    },0);
});

结果:

start
children4
children2
children3
children5
children7
children6
原文地址:https://www.cnblogs.com/fmy-hmfy/p/13737204.html