In the code below when I call func I get back a promise that resolves after 3 seconds which resolves to another promise. The nested promise then resolves to the number 43 after an additional 3 seconds. My question is why the console.log returns res:43 after 6 seconds instead of unresolved promise after 3 seconds. I .then func2 but I never .then otherFunc
async function func(){
const val = func2().then((other)=>{console.log("res:"+other)})
}
async function func2(){
return new Promise(resolve => {
setTimeout(()=>resolve(otherfunc()),3000)
})
}
async function otherfunc(){
return new Promise(resolve => {
setTimeout(()=>resolve(43),3000)
})
}