Morden Browser:
- Chrome
- Firefox
- Safari
- Edge
Features:
- Classes
95.5%
class Profile extends Widget {
constructor() {
super();
}
static load() {
return apiCall('/profile');
}
}
- Arrow functions
96%
const add = (a, b) => a + b
class Profile {
update() {
Profile.load().then(data => {
this.render(data);
});
}
}
- Generators
96%
function* search(node) {
if (!node) return;
yield node;
yield* search(node.firstChild);
yield* search(node.nextSibling);
}
for (let node of search(document)) {
if (node.localName === 'title') {
console.log(node.textContent);
break;
}
}
- Block Scoping
95%
const events = {
click: log,
mouseup: log
}
for ( let type in events ) {
let fn = events[type];
addEventListener(type, function(e) {
fn(e);
});
}
- Destructuring
94%
function add({a, b=0}) {
return a + b;
}
const { x, y, z=0 } = { x:1, y:2 };
const [ a, ...rest ] = 'abc'.split('');
- Rest & Spread
94%
function h(a, b, ...c) { }
Math.max(...[1,2,3]);
let unique = [...new Set([1, 2, 2, 3])];
- Object Shorthand
95%
let a = 1, b = 2;
const obj = {a, b};
const Myth = {
random() { return 42; }
}
- Async / Await
95%
class Profile {
async update() {
this.render(await Profile.load());
}
}
for (const a of document.links) {
const res = await fetch(a.href);
if (!res.ok) a.classList.add('gone');
}
PS : 一些 WebAssembly 相关的资料