一道有趣的编程题

日前跟朋友交流过一点关于promise的知识,想了一道题。看到的朋友不妨给个答案,当娱乐一下自我吧。

var promise = new Promise((resolve, reject) => {console.log(1); resolve();});

setTimeout(() => {console.log(2)}, 0); 

promise.then(() => {var promise1 = new Promise((resolve, reject) => { console.log(3); resolve(); });

setTimeout(() => {console.log(4)}, 0);

promise1.then(() => {console.log(5)}) }); 

console.log(6);

推荐阅读更多精彩内容