You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Promise.resolve().then(()=>console.log('first async task'))vartotal=0asyncfunctionadd(num){// await only delay the assignment operation// that's how js works in assignmenttotal=(console.log('total expression before await',total)||total)+await(console.log('await expression')||num)console.log('assignment finished!')}add(1)add(2)setTimeout(()=>console.log(total))
Promise.resolve().then(()=>console.log('first async task'))vartotal=0asyncfunctionadd(num){// await only delay the assignment operation// that's how js works in assignmenttotal=await(console.log('await num')||num)+(console.log('add total',total)||total)console.log('assignment finished!')}add(1)add(2)Promise.resolve().then(()=>{console.log(total)})
https://www.cnblogs.com/xianshenglu/p/8150163.html
The text was updated successfully, but these errors were encountered: