The following code:
function log() {
console.log('ok');
}
function log2() {
console.log('ok2');
}
async function run() {
await log();
await log2();
}
run();
console.log(1);
Returns:
ok
1
ok2
The question is: being "run" an async function shouldn't it execute after all synchronous calls? (Such as console.log(1)). Actually the one that executes after the sync call is the second await.
The return value should be:
1
ok
ok2
Why does the first await executes synchronously?