new Promise((resolve, reject) => {
console.log('外部promise') resolve()}) .then(() => { //then1 console.log('外部第一个then') new Promise((resolve, reject) => {
console.log('内部promise') resolve() }) .then(() => { //then2 console.log('内部第一个then') }) .then(() => { //then3 console.log('内部第二个then') }) }) .then(() => { //then4 console.log('外部第二个then') }) .then(() => { //then5 console.log('外部第三个then') }) .then(() => { //then6 console.log('外部第四个then') })
这是上周小米二面的时候面试官出的一道读代码题,当时写到一半的时候面试官就说不对然后给了一些提示,然而还是没有回答出来...在面试结束之后自己做了个断点调试,