const function1 = () => new Promise(function(resolve,reject) { setTimeout(() => { resolve(10) },6000) }); const function2 = async () => { console.log("first"); const val = await function1() console.log("second"); return val } console.log("third -- " ,function2()) I was exepecting the order of the message as below:
first second third -- Promise { <pending> }> But it turns out to give the below output:
first third -- Promise { <pending> } second can anyone please help me understanding this ?