Async function with +=

后端 未结 5 2043
礼貌的吻别
礼貌的吻别 2020-12-24 11:39



        
5条回答
  •  忘掉有多难
    2020-12-24 12:04

    Your statement x += await 5 desugars to

    const _temp = x;
    await;
    x = _temp + 5;
    

    The _temporary value is 0, and if you change x during the await (which your code does) it doesn't matter, it gets assigned 5 afterwards.

提交回复
热议问题