• Home
  • blog
  • Editorial: Are You Writing ES6 JavaScript Yet?

Editorial: Are You Writing ES6 JavaScript Yet?

When was the last time you wrote some ES6 code? A recent developer survey called The State of JavaScript reported that 74% of respondents have already used the new syntax and intend to do so again. A further 21% have heard of it and are interested in learning. The ES2015 version of JavaScript (referred to as ES6 from here on) has been an official standard for almost a year and a half now, but it still seems like a lot of blog posts, articles, and tutorials are still being published that use the older ES5 syntax.

This past week, I spent some time working on a Chrome extension. One of the nice things about developing Chrome extensions is that the browser is fixed, and so you know what features are supported. The decision was made that the extension would be written in ES6-flavored JavaScript, which worked out well for me as I’ve recently been trying to utilize ES6 in my code whenever possible, in order to become fluent with the new syntax.

Of course, it’s not just Chrome that can run ES6 natively. Support for the new standard has come on leaps and bounds, with the latest releases of the major desktop browsers all complying with over 90% of the specification (with tail call optimization being the last major outstanding feature). The current releases of both Node 6 and 7 have similarly good levels of support. Of course, most of the time we don’t have the luxury of just coding for compliant browsers – we have to support mobile browsers (which still lag being in their support for ES6) and, naturally, older versions of IE.

Thankfully, we don’t have to give up on using modern JavaScript to support legacy engines thanks to the ability to transpile (convert the source code) to ES5-compatible code. This is sometimes mentioned as a reason against adopting ES6 at the current time, but I don’t find that a convincing argument. For a start, most real-world applications are going to be using a build step of some sort already; compiling SASS/Less, bundling modules, or, at the least, concatenating files. More significantly, it looks like transpiling will be with us for the foreseeable future. Even when the majority of users’ browsers support ES6 natively, we’ll most likely still be transpiling in order the latest and greatest version of the standard (ES2020, anyone?).

Continue reading %Editorial: Are You Writing ES6 JavaScript Yet?%