ES6
wut?
Arrows
var compute = a => a * 3;
Classes
class Shape {
render() {
console.log("Shape");
}
}
class Triangle extends Shape {
render() {
super.render();
console.log("Triangle");
}
}
Literal Objects
var shape = {
render() {
console.log("Shape");
}
};
Destructuring
var shape = {
width: 5,
height: 8,
};
var { width, height } = shape;
Variadic Arguments
function log(message, ...data) {
console.log(message);
console.log(data);
}
log("ERROR", 3, "crash");
Let
let x = "Bob";
let x = "Alice"; // <<
// ERROR: Duplicate declaration
Const
const x = "Bob";
x = "Alice"; // <<
// ERROR: x is read-only
Sets, Maps, etc.
var s = new Set();
s.add("Bob");
console.log(s.has("Bob"));
PHP
var what = "World";
var result = `Hello ${ what }`;
(Template Strings)
Also:
Iterators
Proxies
Unicode
Promises
Modules
Math, Array functions
Questions/Discussion?
What is new in ES6?
By nercury
What is new in ES6?
- 1,177