ES6 Cheatsheet

From Code Self Study Wiki
Jump to: navigation, search

Quick notes about ES6.

Syntax[edit]

Arrows and Template Strings[edit]

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

Classes[edit]

 

let and const[edit]

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

Enhanced Object Literals[edit]

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