Welcome JavaScript 2.0

JavaScript dominates the web - and ECMAScript, the core of the language is growing up. the new specification (ES6 or JS2), which is expected in the middle of this year, brings a lot of new features that you can already try out today. Firefox currently brings the best support, but polyfills through so-called transpilers like Google Traceur are also possible. Below is a short overview of the new features of ES6.

The new keyword let does a lot better than var: Scoping behaves exactly the same as in other languages (C/C++, Java), which is why if blocks now have their own scope, and the hoisting, i.e. the preference of variable declarations (not value assignments) within the respective scope, is also repaired:

var x = 'foo'; 
// undefined

let y = 'bar';
// not initialized

The number of other innovations is long: 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 multitude of new functions (repeat (), contains (), startsWith (), find (), findIndex ()), the new loop construction for ... of.

The new data types set, map, proxy and symbol, the import of (parts of other) JavaScript files with import and a new intuitive syntax for classes and inheritance should also be mentioned. But often there are also small but long-awaited things like the possibility of line breaks in string literals (note the special quotation marks):



JavaScript has long been much more than a tool for little web page tricks - it creates powerful, high-performance web applications that are in no way inferior to their desktop counterparts. With the huge amount of helpful new features and ES6's existing support, programming is twice as much fun.

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)