• ES 5, December 2009 ◦ JSON, Array.prototype.forEach(), ... • ES 5.1, June 2011 ◦ Just document correction of ES 5 • ES 6, June 2015 • ES 7, June 2016 ◦ Array.prototype.includes, Exponentiation operator (**) • ES 8, June 2017 ◦ await/async, Object.entries() and Object.values(), ...
ECMAScript 2016 (ES7) • ES6 was too large • Each proposal goes through stage 0 to stage 4 • Standard releases yearly • http://exploringjs.com/es2016-es2017/ch_tc39-process.html
and let are block-scoped var x = 3; function func(randomize) { if (randomize) { var x = Math.random(); // (A) scope: whole function return x; } return x; // accesses the x from line A } func(false); // undefined let x = 3; function func(randomize) { if (randomize) { let x = Math.random(); return x; } return x; } func(false); // 3
but does not make the value immutable const z = 1; if (true) { const z = 3; console.log(z); // z = 3 } console.log(z); // z = 1 z = 5; // error: assignment to constant variable const obj = {a: 3}; console.log(obj.a); // 3 obj.a = 5; console.log(obj.a); // 5 obj = {a: 5}; // error: assignment to constant variable
x => { ... } // one parameter, an identifier (x, y) => { ... } // several parameters x => { return x * x } // block x => x * x // expression, equivalent to previous line
field declaration in standard yet (stage 3 proposal) class Point { constructor(x, y) { this.x = x; this.y = y; } static defaultPoint () { return new Point(0, 0); } } let point = Point.defaultPoint();