Angular & ECMAScript 6

Getting Started with ECMAScript 6 for AngularJS


ECMAScript 6 (ES6) is around the corner. It is in the last step of specifications and every browser have started implementing its features.

However, only fewer developers have started writing with it, the reason: partial support. Indeed, as for May 2015, there is still a lot of work to do. Even Chrome/Webkit, which is considered for many as the ultimate browser, is only at a mere 50% whereas the most hated browser known as IE, as for the latest release, is beating them all with a full 72%.

But there is no fear to have, because nowadays, we have transpilers.

What are transpilers?

Transpiler = Transformer + Compiler.

Transpilers are tools that converts a language into another language (not to confound with compilers that converts into machine code). There are transpilers in almost every famous language: C#, Java, HTML, CSS... but by far the most common are for Javascript.

According to https://github.com/jashkenas/coffeescript/wiki/List-of-languages-that-compile-to-JS there are more than 270+ transpilers out there, almost for every existing language: C#, Haskell, Clojure... But what interests us today is the ability to compile "Javascript into Javascript", e.g. to be able to make use of the latest features of the language without needing to wait for the browsers to support them!

The two most famous transpilers out there are Traceur Compiler and Babel (formerly 6to5), though Babel is way more advanced than Traceur to this date.

Thanks to transpilers and task runners, it is now possible to write ES7 compliant code without having to wait for the next browsers.

For more information, take a look at the presentation I made for the ng-conf: https://slides.com/eliorboukhobza/angular-ecma6