美文网首页
js promise/setTimeout/async&awai

js promise/setTimeout/async&awai

作者: 空天啸鹤 | 来源:发表于2023-06-28 09:35 被阅读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

相关文章

网友评论

      本文标题:js promise/setTimeout/async&awai

      本文链接:https://www.haomeiwen.com/subject/ocdoydtx.html