News

ES6: How it impacts JavaScript

What does the latest update to JavaScript have to offer?

JSlogo

What does the latest update to JavaScript have to offer?

JSlogo

JavaScript is available in a variety of forms today like that of web browsers, native applications, server-side scripting and even more exotic environments. As a language, it is steered by a standard called ECMAScript, which sets the core syntax and features of JavaScript.

As each version of the ECMAScript standard is ratified, JavaScript engines move to support the changes detailed within it. This provides JavaScript with a general compatibility between implementations of the language. Code written to work in web browsers, that aren’t tied to anything browser specific (like the DOM), should work in other JavaScript engines like Node.js.

ECMAScript 6 (referred to as ES6) is the next version of this standard for JavaScript and is nearing its final release, meaning that the features are set and that implementations are fully detailed and unlikely to change in any significant way. Browsers, scripting engines and other applications have already started adding support for ES6 with Firefox and Chrome leading the way. Once it’s been officially finalised, expect full support of the standard to be taken up quickly by the major applications.


“ES6 will introduce new syntax and features to JavaScript, designed to make life easier for developers and solve common programming problems”


ES6 will introduce new syntax and features to JavaScript, designed to make life easier for developers and solve common programming problems. The goals state that it intends to make the language better for writing complex applications, libraries and code generators so they’ve included a module system that is reuseable and can be used to improve code organisation. Class support is now built in with its own syntax, and methods have been added to help manage asynchronous code, such as promises and generators.

At lower levels there are new variable types to provide alternatives to objects and arrays for your data, known as ‘sets’ and ‘maps’. Building strings from several variables has also been improved through a new template string syntax, which can also be used to easily create multiline strings without being split. Defining functions has also received attention through a new ‘fat arrow’ syntax, which can help with the often confused nature of the ‘this’ scope in relation to the function being called. Recursive functions can take advantage of performance improvements by returning at their end. Block-scoped variables, constants, default parameters and much more make this quite the upgrade for JavaScript.

What does this all mean for developers? On offer is better code organisation, plenty of new shortcuts for typical tasks, standard formats for sharing libraries and much more. There’s also nothing holding you back from using the major features of ES6 now. Applications are available that will take your ES6-based code and compile it into ES5, making your code compatible with a wide range of JavaScript engines that are in use today.

READ MORE ABOUT ES6 in Web Designer 235

×