js promise/setTimeout/async&awai

2023-06-28  本文已影响0人  空天啸鹤

console.log('script start');

async function async2(params) {
console.log('async2 end');
}

async function async1(params) {
await async2();
console.log('async1 end');
}

async1();

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

new Promise((resolve) => {
console.log('promise');
resolve();
})
.then(function () {
console.log('promise1');
})
.then(function() {
console.log('promise2');
});

console.log('end')
VM949:1 script start
VM949:4 async2 end
VM949:17 promise
VM949:27 end
VM949:9 async1 end
VM949:21 promise1
VM949:24 promise2

VM949:14 setTimeOut

上一篇 下一篇

猜你喜欢

热点阅读