Skip to content

Instantly share code, notes, and snippets.

@jefflau
jefflau / es6Part1.md
Last active October 3, 2015 09:39
A journey through ES6 - Part 1

A journey through ES6 - Part 1

I’ve just started learning ES6 properly and to help others I’m going to document what I’ve learnt through a series of blog posts. In this post we’re going to start with the most basic parts of ES6 that you can jump into straight away. let and const are two new keywords for defining variables. Both are really simple to use and solve some problems in the JavaScript language. 

##let

We’ll start looking at let first. JavaScript’s scoping is done with functions. That means anything declared as a var inside a function closure will be only accessible within the function. One thing JavaScript didn’t have before ES6 was block scoping, and that is where let comes into play. Block scoping is scoping within a ‘block’. That block is denoted by the { ... } curly braces in JavaScript.

let allows you to create block scopes

@jefflau
jefflau / destructuring.md
Last active October 3, 2015 10:09
A journey through ES6 - Part 3

#Destructuring

Destructuring is a very useful technique in ES6. It allows you to 'break down' or 'deconstruct' an object into variables. Think of it like flattening the object so all the properties and value come out as normal variables.

##Simple Example

var obj = {
  a: 1,