Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Microsoft Enables Async/Await in Edge Preview Build

Microsoft Enables Async/Await in Edge Preview Build

This item in japanese


Microsoft's Edge browser has enabled the upcoming async/await feature of ES 2016. The feature is still behind an experimental flag in a preview build, but its presence is an important step towards widespread adoption.

JavaScript's inherent asynchronous nature is powerful, but it can also burden developers with excessive code for simple jobs. "Callback hell" is a joke JavaScript developers smile and nod at in dismay. In recent years, developers embraced Promises which enable a better way to deal with async code. Promises have advanced enough to become part of the ES6 spec.

The async/await feature takes Promises a step further, eliminating the need to wire up all the callback pieces required by traditional Promises. In an example where a function getJsonAsync returns a Promise, using async/await allows developers to wire up that same promise in a more synchronous style.

async function getServerData() {
    try {
        // Once the promise is resolved, the value is returned
        var json = await getJsonAsync();
    catch (e) {
        // If the promise is rejected, the result ends up in the catch block

C# developers may find the syntax familiar; Microsoft introduced async/await for C# 5.0. In C#, the feature allows developers to write asynchronous code in a synchronous manner, without the need to explicitly wire up excessive code. Similarly, async/await in JavaScript is sugar, reducing the need for boilerplate code.

The feature is available in build 10547 as part of the Windows Insider program. The "Enable experimental JavaScript features" flag must be enabled in the about:flags window.

For now, the feature is not available in other browsers. However, the Babel transpiler has support for it as an experimental feature. Support in other browsers is likely not far behind. Mozilla is working on it.

Implementation in browsers is a necessary step in the ECMAScript standards process. Async/await is currently at stage 3, "Candidate". For a proposal to move on to the final stage 4, implementation experience is necessary. The feature's champion, Brian Terlson, spoke about this feature and the TC39 ES2016 process at this year's QCon New York.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p