I’m confused and a little worried about how this code is handled in JavaScript:
condition: boolean = setCondition();
if (condition){
await doAsyncStuff();
}
doFinalStuff();
If await
is just syntactic sugar for doAsyncStuff().then(doFinalStuff())
how is the above code handled?
Something like:
if (condition){
doAsyncStuff().then(doFinalStuff());
} else {
doFinalStuff();
}
Seems less elegant than what I would have expected from JavaScript. is my code wrong? Does it not perform as expected? How would I fix it?