As a die-hard java-developer for several years I was quite annoyed by the fact that Java as a language lagged several years behind C#. (E.g. Java got lambdas last year, 6 years after C#, so standards are nice for compatibility, but tends to be slow to evolve.)
Another new nice feature is for finding the first item in an array. It used to be written like this:
And now it can be written like:
ECMAScript 6 is feature complete, and is started to be supported by modern browser like Chrome, Firefox and Internet Explorer 11. As for older browsers, great polyfills like core-js come to our rescue.
While polyfills extend current objects with new methods, ECMAScript 6 also contains new language syntax. Let’s look at the arrow function (also known as fat arrow):
Older browser will not understand “=>” (for a long time!), so this code has to be transpiled to ECMAScript 5:
This will transpile to:
This will be transpiled to the following, not very readable, but working code:
ECMAScript 6 is here, and we should start using it. Older browser will be around for a long time, so I think we should get used to transpiling code on the web-platform.
Tor Arne Senior developer