Learning ES6

Below you will find code examples for the different features of ES6 based on the Learning ES6 blog series. There are examples that attempt to run ES6 natively in the browser as well as those that run ES6 code transpiled to ES5 using Babel or Traceur. See Using ES6 right now for more information.

Check out the learning-es6 Github repository for all of the source code.

Arrow functions

A short-hand form of an anonymous function

Block scoping

Scoping variables to blocks via let keyword


A formalized approach to define classes in JavaScript


A concise yet flexible way of mapping values from objects or arrays into variables

Enhanced object literals

Various shorthand syntaxes for building up object literals


Specialized functions that create iterators using the yield keyword

Iterators and Iterables

A new ES6 interface for custom iteration that doesn't require creating an array


Provide a modular of organizing and loading JavaScript code

New APIs

New APIs for existing native JavaScript classes Math, Object, RegExp, etc.

New Collections

New Map, Set, WeakMap & WeakSet collections.

Parameter handling

More ways to deal with the arguments to a function


An alternative to callback functions for handling asynchronous operations

Template literals & tagged templates

Much cleaner way to build up string values