ECMAScript 2018 Is Feature Complete
ECMAScript 2018 Is Feature Complete
Written by Ian Elliot   
Monday, 05 February 2018

What's new in JavaScript/ES2018? Not much, but keep your eye on what is happening or it might just come as a surprise.

JSlogo

Although the new TC39 process, which pushes new JavaScript features through the approvals mill one at a time, makes the yearly release less important it still produces a bundle of changes that we can discuss. Yes it's ES2018 already.

So what is new?

Not a great deal, and this is a good, not bad, thing. JavaScript should be a mature language by now and after the huge changes in ES2015 we need some stability.

Probably the most important of the new features is Asynchronous iteration. Synchronous iteration, introduced in ES2015, lets you write:

var array=[1,2,3];
for(let value of array){
 console.log(value);
}

The new feature extends this to long running asynchronous operations using await:

for await(let value of getValueAsync(){
 console.log(value);
}

which doesn't block the UI thread while waiting for the asynchronous iterator. You can, of course, create your own asynchronous  iterables. The only problem is that the feature isn't widely supported as yet, but all of the JavaScript engines are being updated to include it.

The next biggest feature is probably the rest spread operator and you might be forgiven for thinking that this was already in JavaScript. The rest operator works in ES2015 on arrays and now in ES2018 on objects. If you destructure an object you can now add ... to signal that any remaining properties should be packed into the final variable. For example:

let {x,y,...z}={x:1,y:2,a:3,b:4};

stores 1 in x, 2 in y and {a:3,b:4} in z i.e. the rest of the object. Similarly the spread operator now works in objects:

let n = { x, y, ...z };

gets us back to our original object {x:1,y:2,a:3,b:4}

We also have some new features in regular expressions: named capture groups, unicode property escapes, lookbehind assertions and s(dotAll) flag. JavaScript has had numbered groups for a while, but now you can assign an id and use that id in a backreference etc. Unicode property escapes extend the classification of characters to unicode properties such as Greek characters,Currency_Symbol and so on. Lookbehind assertions are a generalization of lookahead assertions and are likely to make regular expressions even harder to understand!

Finally we have finally.

Well Promise.finally to be exact. As we reported on the release of Firefox 58, you can now use the Promise finally method to run code no matter how the Promise resolves.

What can we expect for ES2019?

Of the proposals close to being completed, the idea of adding 64-bit integers is likely to be the most useful. If you want to use JavaScript like a class-based language then you might also like public and private fields - just add a # to the front of a property name and it becomes private. It may be backward compatible, but it introduces the sigil into JavaScript and should be resisted for this reason alone.

 

JSlogo

More Information

https://github.com/tc39/proposals

Related Articles

Firefox 58 - Tab Throttling, WebAssembly, Promise Finally And Progressive Web Apps

ECMAScript 2016 Approved

JavaScript The Language With Two Names    

The JavaScript Encyclopedia Work In Progress 

JavaScript Added To Oxford English Dictionary 

JavaScript 6 EcmaScript 2015 Final Approval 

JavaScript 20 Years Old Today 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

Banner


JetPack And Android Studio 3.2 - Not Much New
09/05/2018

Google I/O used to be an exciting meet up where really new and startling things were announced. Now it's past its best and Googler's have to work hard to package the dull into something that looks exc [ ... ]



Facebook Advances in AI At F8
04/05/2018

Facebook is one of the big technology companies that is making a big investment in AI and at F8 it was ready to share some of its latest progress. The good news is that Facebook is open-sourcing its A [ ... ]


More News

justjsquare

 



 

Comments




or email your comment to: comments@i-programmer.info

 

Last Updated ( Monday, 05 February 2018 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.