I know we all use promises to avoid function callback hell, but my question is where in the event loop the promise code runs and whether the code is really asynchronous.
I mean, is this code asynchronous just because it's run within a promise?
Or is the promise not a part of the event loop?
const p = new Promise((resolve,reject) =>{
resolve('am i part of the event loop ? , am i a diffrent thread ? or am i synchronized? ')
})
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…