cheatsheets/es6.md

1.1 KiB

title layout
ES6 default

Stable

New features you can use on io.js.

Promises

new Promise(fn)
  .then(fn)
  .catch(fn)

Promise.all(...)
Promise.race(...)
Promise.reject(...)
Promise.resolve(...)

Template strings

var message = `Hello there ${name}`;

Block scoping

if (true) {
  let x = 1;
}

Constants

const a = 1;

Generators

function*() {...}

Binary/octal

var bin = 0b1010010;
var oct = 0755;

String methods

"hello".repeat(3)
"hello".contains("ll")
"\u1E9B\u0323".normalize("NFC")

Symbols

var sym = Symbol("foo")
typeof sym === 'symbol'

Collections

Map, WeakMap
Set, WeakSet