"ECMAScript was always an unwanted
trade name that sounds like a skin
disease.
https://mail.mozilla.org/pipermail/es-discuss/2006-October/000133.html
Brendan Eich,
uitvinder van JavaScript
Slide 8
ECMA-262
Slide 9
ECMA-420
Dart programming language
Slide 10
ECMA-222
Adaptive Lossless Data Compression Algorithm
Slide 11
ECMA-74
Measurement of Airborne Noise Emitted
by Information Technology
and Telecommunications Equipment
Slide 12
ECMA-262
ECMAScript® Language Specification
Slide 13
ActionScript
Slide 14
Adobe ExtendScript
Slide 15
JScript
Slide 16
V8
SpiderMonkey
Chakra
Slide 17
JavaScript
Slide 18
ECMA-262 6th edition
The ECMAScript® 2015
Language Specification
•
new Math, Number, String, Array, Object APIs
•
Modules
•
Promises
•
Proxies
•
Reflect API
•
Subclassable Built-ins
•
Symbols
•
Ta i l C a l l s
•
Template strings
•
Unicode (full support)
ES6
var
name = 'Paul Verbeek';
}
console.log(name);
// Paul Verbeek
}
logPaul();
Slide 26
function
logPaul() {
var
name = undefined;
if (true) {
name = 'Paul Verbeek';
}
console.log(name);
// Paul Verbeek
}
logPaul();
Slide 27
function
logPaul() {
if (true) {
let
name = 'Paul Verbeek';
}
console.log(name);
// name is not defined
}
logPaul();
Slide 28
function
logAllThePauls() {
var
pauls = ['Paul Verbeek',
'Paul McCartney',
'Paul Simon’];
for
(
var
i = 0; i < pauls.length; i++) {
console.log(pauls[i]);
}
console.log(i);
// 3
}
logAllThePauls();
Slide 29
function
logAllThePauls() {
let
pauls = ['Paul Verbeek',
'Paul McCartney',
'Paul Simon’];
for
(
let
i = 0; i < pauls.length; i++) {
console.log(pauls[i]);
}
console.log(i);
// i is not defined
}
logAllThePauls();
Slide 30
var
globalVar = 'global variable';
let
globalLet = 'also global';
function f() {
var
functionVar = 'function-scoped';
let
functionLet = 'this one too';
}
f();
Slide 31
function
logPaul() {
let
name = 'Paul Verbeek';
let
name = 'Paul McCartney';
// Identifier 'name' has already been declared
console.log(name);
}
logPaul();
Slide 32
function
logConstantPaul() {
const
paul = 'Paul Verbeek’;
paul = 'Paul Simon';
// 'paul' is read-only
console.log(paul);
}
logConstantPaul();
Slide 33
function
logConstantPaul() {
const
paul = {
firstName: 'Paul',
lastName: 'McCartney'
};
paul = 'Verbeek';
console.log(paul.lastName);
// Verbeek
}
logConstantPaul();
Slide 34
function
logConstantPaul() {
const
paul = {
firstName: 'Paul',
lastName: 'McCartney'
};
paul = {};
// 'paul' is read-only
}
logConstantPaul();
Slide 35
Temporal Dead Zone (TDZ)
TEMPORAL
Slide 36
console.log(typeof foo);
// ReferenceError
console.log(typeof bar);
// 'undefined'
let
foo = 'inner scope’;
var
bar = 'inner scope’;
Slide 37
let
foo = 'outer scope';
(
function
() {
console.log(typeof foo);
// ReferenceError
let
foo = 'inner scope';
}());
Slide 38
const? let? var?
Gebruik altijd
const
, behalve als
je variabele moet kunnen
veranderen.
Gebruik anders
let
.
Slide 39
Block-scoped variables
Slide 40
Template strings
Slide 41
console.log('In ECMAScript 5.1 is
dit een error.’);
// Uncaught SyntaxError: Unexpected token ILLEGAL
console.log(In ES6 zal dit een nieuwe regel geven.);
//
In ES6 zal dit
//
een nieuwe regel geven.
Slide 42
Een wat?
Slide 43
Een backtick
of accent grave
Dus: `
in plaats van: '
Slide 44
var location = 'PFCongres',
topic = 'ES6';
console.log('Bij ' + location + ' over ' + topic + ' aan het
praten');
// Bij PFCongres over ES6 aan het praten
const location = 'PFCongres',
topic = 'ES6';
console.log(Bij ${location} over ${topic} aan het praten);
// Bij PFCongres over ES6 aan het praten
// ES5.1
setTimeout(
function
() {
console.log('foo');
}, 100);
var
square =
function
(x) {
return
x * x; };
// ES6
setTimeout(() => {
console.log('foo');
}, 100);
const
square = x => x * x;
Slide 58
const
arr = [1, 2, 3];
let
square;
// ES5.1
square = arr.map(
function
(a) { return a * a; });
Minder typen
// ES6
square = arr.map(a => a * a);
Slide 59
// ES5.1
function
Interface() {
var
that =
this
;
var
button = document.getElementById('myButton');
button.addEventListener('click',
function
() {
console.log('CLICK');
that.handleClick();
});
}
Interface.prototype.handleClick =
function
() { ... };
2. Niet meer '
var that=this
'
this
.handleClick();
});
}
Interface.prototype.handleClick =
function
() { ... };
2. Niet meer '
var that=this
'
Slide 61
Arrow functions
(
λ
expressions)
Slide 62
Classes
Slide 63
function
Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
Person.prototype.fullName =
function
() {
return
this
.firstName + ' ' +
this
.lastName;
};
Person.prototype.toString =
function
() {
return 'Mijn naam is ' +
this
.fullName();
};
var
me = new Person('Paul', 'Verbeek');
console.log(me.toString());
// Mijn naam is Paul Verbeek
Slide 64
class
Person {
constructor
(firstName, lastName) {
this
.firstName = firstName;
this
.lastName = lastName;
}
get
fullName () {
return
${ this .firstName} ${ this .lastName};
}
toString () {
console.log(Mijn naan is ${ this .fullName});
}
}
const
me =
new
Person('Paul', 'Verbeek');
console.log(me.toString());
// Mijn naam is Paul Verbeek
Slide 65
class
Person {
...
}
class
Employee
extends
Person {
constructor
(firstName, lastName, company) {
super
(firstName, lastName);
this
.company = company;
}
toString () {
return
${ super .toString()} en ik werk bij ${ this .company};
}
}
const
me =
new
Employee('Paul', 'Verbeek', 'Booking.com');
console.log(me.toString());
// Mijn naan is Paul Verbeek
// en ik werk bij Booking.com
Slide 66
Classes
Slide 67
Default, rest and spread
Slide 68
multiply(3);
// 6
multiply(3, 3);
// 9
function
multiply(x, y) {
if (typeof y === "undefined") { y = 2; }
return
x * y;
}
Slide 69
multiply(3);
// 6
multiply(3, 3);
// 9
function
multiply(x, y = 2) {
return
x * y;
}
Slide 70
addOne(3, 7, 14); // [4, 8, 15]
function
addOne() {
var
numbers = Array.prototype.slice.call(arguments);
return
numbers.map(function (number) {
return number + 1;
});
}
Slide 71
addOne(3, 7, 14); // [4, 8, 15]
function
addOne(...numbers) {
ECMA-262 6th edition
The ECMAScript® 2015
Language Specification
Slide 78
Waar ik het niet over heb gehad
•
Binary and Octal Literals
•
Destructuring
•
Generators
•
Iterators + for..of
•
Map + Set + WeakMap + WeakSet
•
Modules
•
new Math, Number, String, Array, Object APIs
•
Promises
•
Proxies
•
Reflect API
•
Subclassable Built-ins
•
Symbols
•
Ta i l C a l l s
•
Unicode (full support)
Slide 79
ECMA-262 7th edition
The ECMAScript® 2016
Language Specification
Slide 80
ES2016
Slide 81
x ** y
exponentiation operator (**)
Math.pow(x, y);
let
a = 3;
a **= 3;
// a = 27