事件循环Event Loop
https://segmentfault.com/a/1190000013102056
https://www.cnblogs.com/intangible/p/8066979.html
console.log('1');
setTimeout(function() {
console.log('2');
process.nextTick(function() {
console.log('3');
})
new Promise(function(resolve) {
console.log('4');
resolve();
}).then(function() {
console.log('5')
})
})
process.nextTick(function() {
console.log('6');
})
new Promise(function(resolve) {
console.log('7');
resolve();
}).then(function() {
console.log('8')
})
setTimeout(function() {
console.log('9');
process.nextTick(function() {
console.log('10');
})
new Promise(function(resolve) {
console.log('11');
resolve();
}).then(function() {
console.log('12')
})
})
//1 7,6,8,2,4,3,5,9,11,10,12
本文深入探讨了JavaScript事件循环机制,详细解释了同步代码、setTimeout、process.nextTick和Promise在执行顺序中的作用,帮助读者理解JavaScript异步编程的核心原理。

被折叠的 条评论
为什么被折叠?



