问:下面代码执行后输出什么?
setTimeout(function(){
console.log(1)
new Promise(function(resolve2){
console.log(8);
resolve2()
}).then(function(){
console.log(9)
setTimeout(function(){
console.log(10)
});
});
});
new Promise(function(resolve){
console.log(2);
for(var i = 0; i < 10000; i++){
i == 9999 && resolve();
}
new Promise(function(resolve2){
console.log(5);
resolve2()
}).then(function(){
console.log(6)
setTimeout(function(){
console.log(7)
});
});
}).then(function(){
console.log(3)
});
答案:2,5,6,3,1,8,9,7,10