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.
A short-hand form of an anonymous function
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
Various shorthand syntaxes for building up object literals
Specialized functions that create iterators using the
yield
keyword
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 for existing native JavaScript classes Math
,
Object
, RegExp
, etc.
New Map
, Set
, WeakMap
&
WeakSet
collections.
More ways to deal with the arguments to a function
An alternative to callback functions for handling asynchronous operations
Much cleaner way to build up string values