I\'m trying to learn async-await. In this code -
const myFun = () => {
let state = false;
setTimeout(() => {state = true}, 2000);
return
There is no point to async and await when this is the actual case:
Promise.resolve(3).then(console.log); console.log(4);
4
3
In other words, since the then() forks and runs slower than the subsequent statements (even for a resolved Promise) then we need to put the subsequent statements inside the then, like:
Promise.resolve(3).then(_ => { console.log(_); console.log(4); });
3
4
And since that is true then why bother to await. So Im yet to see why async and await even exist.