Welcome JavaScript 2.0

JavaScript dominates the web – and ECMAScript, the core of the language, is maturing. The new specification (ES6 or JS2), expected mid-year, brings numerous innovations that can already be tested. Firefox currently offers the best support , but polyfills via transpilers like Google Traceur are also possible. A brief overview of the new features of ES6 follows.


The new keyword let does many things better than var : scoping now behaves exactly like in other languages ​​(C/C++, Java), which is why if blocks now also have their own scope. Hoisting, i.e. the prioritization of variable declarations (not value assignments) within the respective scope, will also be repaired:

console.log(x);
var x = 'foo'; 
// undefined

console.log(y);
let y = 'bar';
// not initialized

The number of other innovations is large: constants (const), default values ​​for functions (function pow(a,b=2) { return Math.pow(a,b); }), a new notation for functions (let pow = (a,b=2) => Math.pow(a,b);), a variety of new functions (repeat(), contains(), startsWith(), find(), findIndex()), the new loop construction for ... of.

Also worth mentioning are the new data types Set, Map, Proxy and Symbol, the ability to import (parts of other) JavaScript files with import and a new intuitive syntax for classes and inheritance. But often there are also small but long-awaited things like the possibility of line breaks in string literals (note the special quotation marks):

`foo

bar`

JavaScript has long been much more than just a tool for minor website tricks – it's used to create powerful, high-performance web applications that are every bit as good as their desktop counterparts. With the abundance of helpful new features and the existing support for ES6, programming is twice as enjoyable.

Who hasn't always wanted to check the equality of two numbers with the help of the new constant Number.EPSILON , whose value is the difference between 1 and the next higher floating point value?

let cmp = (a,b) => Math.abs(a-b) < Number.EPSILON;
Back