ECMAScript State of the Union
- Basis of JavaScript
- Standardized by ECMA International
- ECMAScript 3 (Dec. 1999)
- Supported in practically all browsers
- ECMAScript 5 (Dec. 2009)
- Very good supported in all major browsers (compat. table)
- Common basis for most web applications in the public internet
- ECMAScript 2015 aka 6 (June 2015)
- Good support in modern browsers (compat. table)
- Commonly assumed in controlled environments (e.g. intranet, closed groups, embedded browser)
- ECMAScript 2016 (June 2016)
- Partly supported in latest browsers (compat. table)
- Constants (
const
) - Block-scoped-variables (
let
) and -functions
function varTest() {
var x = 1;
if (true) {
var x = 2; // same variable!
console.log(x); // 2
}
console.log(x); // 2
}
function letTest() {
let x = 1;
if (true) {
let x = 2; // different variable
console.log(x); // 2
}
console.log(x); // 1
}
class Polygon {
constructor(height, width) {
this.name = 'Polygon';
this.height = height;
this.width = width;
}
}
class Square extends Polygon {
constructor(length) {
super(length, length);
this.name = 'Square';
}
}
let iterable = [10, 20, 30];
for (const value of iterable) {
console.log(value);
}
for (let value of iterable) {
value += 1;
console.log(value);
}
- Arrow functions
- Function parameters
- Template literals
- Destructuring
- Generators
- Keyed collections
Map
andSet
- Promises (see next slides)
<!--#include file="ecmascript-fundamentals/0010-promise/callback.js" -->
<!--#include file="ecmascript-fundamentals/0010-promise/promise.js" -->
- Async functions with
async/await
similar to C# (will be covered later in more details)
<!--#include file="ecmascript-fundamentals/0020-async/async.js" -->
- "Transpiler"
- Transforms modern JavaScript so that you can run it in old environments
- Especially important for building consumer-facing websites
- Huge ecosystems of plugins
- babel demo
- ECMAScript/JavaScript is no trivial scripting language anymore
- Powerful, modern programming language
- Standard is now moving faster than in the past
- Use babel to enable modern JavaScript in all projects
- What is missing? Types!
Enter: TypeScript
- Want to know more? Read/watch...
- Exercises