Angus Croll: ES6 Uncensored

Orde Saunders' avatarPublished: by Orde Saunders

Angus Croll (@angustweets) was speaking at Full Frontal about ES6, these are my notes from his talk.

As developers we should contribute to the standards and then celebrate them when they are out.  ES6 due out 2014 and the fun police will tell you how not to write it - until then: go wild!  You can write JavaScript in your own way, it's very flexible.

Switch two variables

[a, b] = [b, a] Destructuring. No third var required.

Find the max in array

Math.max(...array); Spread operator turns array into CSV.

Sum an array

Arrow function and rest operator. [Not sure what either of these are?]

Remove duplicates from an array

[...Set(array)] Set is a new type. Also uses spread operator.

Fibonacci sequence

Can use destructuring or generators.


We can use destructuring to replace the with() operator.

Sum of squares

We have array conprehensions for (x of array).

Module pattern

We can use arrow functions to assign defaults.

We can use arrow functions and literal shorthand - in an object litteral the key is defaulted to the var name? [Didn't understand the explanation.]


We can pass in defaults as an object arguments.

Negative array indexes

Can use negative array indexes to work from the end of an array.

Proxies allow us to stub out an operator. Proxies are possibly the hardest syntax in ES6.

Null safe property chains

I.E. Don't need to check for every property up the chain of We can use a proxy to create a recursive proxy chain to work through this.

Where can you use it?

Only by playing with something and making mistakes do we learn. Get a head start on the new stuff.

  • Firefox is the best - still has a few niggles.
  • Chrome - have to enable a flag but only has a subset.
  • node --harmony
  • traceur
  • continuum
  • es6-shim has a compatibility table.

@esdiscuss on twitter is a good place to follow what's going on without getting involved with the mailing list.