JavaScript: What’s new in ECMAScript 2018 (ES2018)?

Object Rest/Spread Properties

When destructuring an object, Object Rest Properties allow you to collect the remaining properties of an object onto a new object. Think of it as a magic magnet attracting all leftovers.

Asynchronous Iteration

With Asynchronous Iteration we get asynchronous iterators and asynchronous iterables. Asynchronous iterators just like regular iterators, except their next()method returns a promise for a { value, done } pair. To consume asynchronous iterables, we can now use the await keyword with for … ofloops.

Promise.prototype.finally()

Promise.prototype.finally() finalizes the whole promises implementation, allowing you to register a callback to be invoked when a promise is settled (either fulfilled, or rejected).

RegExp related features

In total 4 RegExp related proposals made it into ES2018:

Other new Features

To top it off a tweak to template literals landed: when using tagged template literals the restriction on escape sequences are removed, thus allowing things like \xerxes. Before this tweak an error would be thrown because \x is the start of a hex escape with erxes not being a valid hex value.

What now?

Do note that not all these features are readily available in all browsers. Meaning that they’re Stage-4 means that they are finished, and that browser vendors should implement them (some already have, others are in the process).

--

--

#JavaScript geek with a love for semantic HTML and CSS. Also speaks SQL & PHP. Former University Lecturer “Web & Mobile”. Blogs at bram.us. PADI Divemaster.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store