minjs1cn / weekly-learning

每周学习分享打卡
0 stars 0 forks source link

9 -【经典面试】eventloop #9

Open tradyau opened 3 years ago

tradyau commented 3 years ago
console.log('1');

async function async1() {
    console.log('2');
    await async2();
    console.log('3');
}

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

process.nextTick(function () {
    console.log('5');
})

setTimeout(function () {
    console.log('6');
    process.nextTick(function () {
        console.log('7');
    })
    new Promise(function (resolve) {
        console.log('8');
        resolve();
    }).then(function () {
        console.log('9')
    })
})

async1();

new Promise(function (resolve) {
    console.log('10');
    resolve();
}).then(function () {
    console.log('11');
});

console.log('12');
Guyidingsanyu commented 3 years ago

https://mp.weixin.qq.com/s/AZsRMuD3ldth6NSjfWcnIg

Brand0n-Zhang commented 3 years ago

https://github.com/Amarok1217/rumination/blob/master/JavaScript%E7%9B%B8%E5%85%B3/%E8%BF%90%E8%A1%8C%E6%97%B6/%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF/JS%E7%9A%84%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF.md

tradyau commented 3 years ago

https://segmentfault.com/a/1190000019494012

FE92star commented 3 years ago

https://juejin.cn/post/6844903512845860872