ES6 is awesome

JavaScript für den modernen Programmierer von heute

> whoami_

krnl.de logo

Kai Dorschner

Freelancer & Frontend Developer

http://krnl.de

ES6 ===

July 12, 2011
First working draft
August, 2014
Feature Freeze
June 17, 2015
ECMA-262 Edition 6 standard

The Fuss and what it is about

  • Block scoping let x = 1;
  • Arrow Functions [1, 2, 3].map(x => x * x)
  • Modules import fs from 'fs';
  • Classes class HomoSapiens extends HomoErectus {}
  • Default Parameters function point(x = 0, y = 0) {}
  • Rest Parameters function concat(one, two, ...rest) {}
  • Spread Operator new Date(...dateFields)
  • Destructuring [a, b] = [b, a]
  • Generators function* generator() { yield 1; }
  • and soooo much more ...

Work in progress

https://kangax.github.io/compat-table/es6/

Fear not

Transpilers to the rescue

Babel it is

> npm install -g babel_

> node whatever.js_

> babel-node whatever.js_

> babel whatever.js > dist/whatever.js_

> babel whatever.js --watch --out-file whatever-compiled.js_

> babel src/ --out-dir dist/_

Microoptimization

through io.js and .babelrc

> babel-node --harmony_arrow_functions --harmony_classes --harmony_object_literals --harmony_rest_parameters --harmony_scoping --harmony_templates whatever.js

Transpiler Limitations

Due to the limitations of ES5, Proxies cannot be transpiled or polyfilled. See support from various JavaScript engines.

Learn ES2015 # Proxies

... Date, Array and Error cannot be [subclassed] due to ES5 engine limitations.

Learn ES2015 # Subclassable Built-ins

Recommendations

The end