I agree, async/await is very nice. Though it is worth pointing out async/await is quite literally syntactic sugar on top of promises. Essentially adding language syntax for common promise idioms.
Agreed, it's syntactic sugar over es6 generators. But I don't agree that it's just syntactic sugar over promises, which is what the parent comment asserted.
I think it's important to understand this, as when you are interacting with other modules that return promises, you need to know that you can await those, as well as that async functions return promises that can be used as them without being inside another async function.
Like other web standards, these things tend to get implemented in a piecemeal fashion according to consensus and demand. By the time the standards are published, much of their content is already implemented in modern browsers.
For example, the ES6 spec was just published a few months ago, so it will still be a year before we see ES7. In spite of that, the async / await capabilities are sufficiently compelling and agreed upon that patches are already being reviewed for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1185106
Kangax's tables, linked in another reply, are a great way to check what the support situation is like across browsers.
15 comments
[ 3.8 ms ] story [ 48.6 ms ] threadThe best part: you can use it today with babel (I'm using it in browser and on node thanks to the power of webpack, babel and hot reloading).
Or, for that matter, const. Though perhaps const is just syntatic sugar for not reassigning to the same darn name? ;)
Object.defineProperty(this, 'five', { enumerable: true, writable: false, value: 5, configurable: false });
If in global scope, 'five' will look like a const.
WeakMap and WeakSet have polyfills with minor caveats.
I guess you're defining language features as not "syntactic sugar" if they can't be absolutely 100% polyfilled.
because I couldn't find any information on that
For example, the ES6 spec was just published a few months ago, so it will still be a year before we see ES7. In spite of that, the async / await capabilities are sufficiently compelling and agreed upon that patches are already being reviewed for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1185106
Kangax's tables, linked in another reply, are a great way to check what the support situation is like across browsers.