ES6 Cheatsheet

From Code Self Study Wiki
Jump to: navigation, search

Quick notes about ES6.


Arrows and Template Strings

paragraph = `This is a
multiline string`;
hobbits = ['Frodo', 'Bilbo', 'Samwise'];
hobbits.forEach(hobbit => console.log(`The hobbit's name is ${hobbit}.`));



let and const

// Declare a variable
let hobbits;
// Can't be changed
const = maxPlayers;

Enhanced Object Literals

var something = {
    name, // same as name: name
    someFunction() {
        return 'I am a function.';