ECMAScript 6 (ES6) still sounds like something from the future. After all, it will only become a standard by mid 2015. However, its features are continually appearing in browsers and there are compilers that translate ES6 code to ES5 code. The latter is already a compelling solution, because the ECMAScript 6 feature set is already frozen.

This blog post gives a brief overview of ECMAScript 6 features and describes tools that enable you to use them today.

Iterators and generators (iterators are a protocol for retrieving the contents of a collection which is supported by the for-of loop; generators are “pausable functions” that help with implementing iterators and more):

If a template string is prefixed with an identifier (a tag), it becomes a function call: The function referred to by the identifier (the tag handler) is called with the static pieces between the ${} and the results of the expressions inside them. A tag handler can decide whether to accept the static pieces verbatim (“raw”) or with escapes such as \n interpreted (“cooked”). That lets you implement small domain-specific languages. For example, the tag XRegExp.rx is a hypothetical nicer interface to the XRegExp regular expression library:

The backslash at the beginning of the last line (\.html?) is a regular expression backslash. Inside a string literal, it would have to be written as \\.

Symbols

Symbols are a new primitive type in JavaScript. They mainly serve as unique (clash-free) names for properties. For example, an object is marked as iterable via a method whose key is (the symbol stored in) Symbol.iterator. This key cannot accidentally clash with any other property key:

Deploying ES6

ECMAScript 7 and later

Starting with ECMAScript 7, TC39 will time-box releases. The plan is to release a new version of ECMAScript every year, with whatever features are ready at that time. That will result in much smaller releases.

FAQ

How can ECMAScript 5 and ECMAScript 6 exist side by side?

ECMAScript 6 is completely backwards compatible, it is a superset of ECMAScript 5. Details of how the new ES6 features were added to both strict mode and non-strict mode are explained in the blog post “One JavaScript: avoiding versioning in ECMAScript 6”.

Does it still make sense to learn ECMAScript 5?

As we have seen, you can already exclusively write code in ECMAScript 6 and avoid older versions of JavaScript. Does that mean that you shouldn’t learn ECMAScript 5, anymore? Alas, it doesn’t, for several reasons:

ECMAScript 6 is a superset of ECMAScript 5 – new JavaScript versions must never break existing code. Thus, nothing you learn about ECMAScript 5 is learned in vain.

There are several ECMAScript 6 features that kind of replace ECMAScript 5 features, but still use them as their foundation. Two examples: classes are internally translated to constructors and methods are still functions (as they have always been).

As long as ECMAScript 6 is compiled to ECMAScript 5, it is useful to understand the output of the compilation process. And you’ll have to compile to ES5 for a while (probably years), until you can rely on ES6 being available in all relevant browsers, in the same manner in that you can usually rely on ES5 now.