letlaterUsed;doAsyncTask().then(()=>{useVariable(laterUsed||externalAlternativeValue);// ✅ Another value is used when the original value is undefined})
hmmm ...
Even More Correct Usage
doAsyncTask().then(result=>{useVariable(laterUsed)}).catch(e=>{// handle whatever happens when doAsyncTask() goes wrong})
If you're trying to avoid bugs in JavaScript, I'd really recommend
not communicating between asynchronous processes using global variables.
not using undefined to indicate an error state. Or an absence of value.
hmmm ...
Even More Correct Usage
If you're trying to avoid bugs in JavaScript, I'd really recommend
undefined
to indicate an error state. Or an absence of value.😄
Absolutely correct! 😃, may I add it in the post?
Please do! 👍😁