I’m confused and a little worried about how this code is handled in JavaScript:
<code>condition: boolean = setCondition();
if (condition){
await doAsyncStuff();
}
doFinalStuff();
</code>
<code>condition: boolean = setCondition();
if (condition){
await doAsyncStuff();
}
doFinalStuff();
</code>
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:
<code>if (condition){
doAsyncStuff().then(doFinalStuff());
} else {
doFinalStuff();
}
</code>
<code>if (condition){
doAsyncStuff().then(doFinalStuff());
} else {
doFinalStuff();
}
</code>
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?
Thanks for your help,
Greg