I am returning a Promise in an IFFE and the first thing that gets logged is first
but then immediately after that third
is logged and then comes second
. If my setTimeout is in the then
, isn't everything in there synchronously run?
(() => {
return new Promise(resolve => {
console.log("first")
resolve()
})
.then(() => {
setTimeout(() => console.log("second"), 3000)
})
})()
.then(() => console.log("third"))