Async/await in web browser or in node.js?

前端 未结 11 1781
执念已碎
执念已碎 2020-12-29 23:18

Is there any attempt to bring async/await feature from C# 5.0 to any language which can be compiled to JavaScript (such as CoffeScript)? (So it can be used

11条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 00:08

    async/await looks to be coming in ECMAScript 7. This proposal was accepted into stage 1 of the specification process in January 2014.

    The good news is that Googles traceur compiler already supports it, so you could start using it today.

    Sample syntax:

    async function asyncValue(value) {
      await timeout(50);
      return value;
    }
    

    async/await is also on the TypeScript roadmap.

提交回复
热议问题