JavaScript innovaties: ECMAScript 6 & 7

21

Transcript of JavaScript innovaties: ECMAScript 6 & 7

JavaScript InnovationsEcmaScript 6 & 7

JavaScript InnovationsEcmaScript 2015 & 2016

Todayconst, let, default parameters, rest parameter, spread operator, destructuring, arrows, object literals, classes, proxy, iterators, for..of, generators, promise, unicode, normalize, modules, import, export, symbols, subclassing, reflection api, map, set, weakmap, weakset, typed arrays, template strings, string, number, array, math, binary literals, octal literals, regexp, exponentiation operator, object observe, async function...

ES 2015• What is removed?• What is added?

Use today• Internet Explorer?• Edge?• FireFox?• Chrome?• Node?• Babel? Babel???????

Current browser• Shims• https://github.com/paulmillr/es6-shim/

• Transpilers• Babel: https://babeljs.io/• Traceur: https://

github.com/google/traceur-compiler

Limitations of transpilers• ES5

Why is JavaScript Hard?• JavaScript Jabber podcast: http://

devchat.tv/js-jabber/159-jsj-why-javascript-is-hard

Why is JavaScript Hard?• Different implementations

(browsers/transpilers/node/etc.)• Scope• This• Prototype• Verbose syntax• DOM/Array objects are not JavaScript

objects

DEMO

QUIZ

Valid variable declarationsa) constb) varc) setd) let

a, b, d

Valid function declarationsa) function (x) { return x + x; };b) (x) => { return x + x; };c) [Method:] toString() { return "Hello"; }d) x => x + x;

all

Not transpilable featuresa) Modulesb) letc) Proxiesd) Subclassing built-inse) Iterators

c, d (partly)

Criticism• Add only = More complexity

ES 2016• Exponential operator• Object.observe• Async functions

See: https://github.com/tc39/ecma262

Rick [email protected]/rickbeerendonk

Simple. Clear. Software.