This is the first post in a series I’ll be writing that will walk through key features in ES6 and explain how they can be used. I’ll also introduce tools and other languages along the way that can be used to work with ES6 in different browsers as well as on the server-side with frameworks like Node.js. The goal of this first post is to discuss the viability of using ES6 today and point out resources that can help you get started using it. Let’s kick things off by talking about a few of the key features in ES6.
Key Features in ES6
So what are some of the key features in ES6? Here’s a list of some of my favorites:
Arrow functions – A short-hand version of an anonymous function.
Block-level scope – ES6 now supports scoping variables to blocks (if, for, while, etc.) using the let keyword.
Classes – ES6 classes provide a way to encapsulate and extend code.
Constants – You can now define constants in ES6 code using the const keyword.
Default parameters – Ever wished that a function parameter could be assigned a default value? You can do that now in ES6.
Destructuring – A succinct and flexible way to assign values from arrays or objects into variables.
Generators – Specialized functions that create iterators using function* and the yield keyword.
Map – Dictionary type object that can be used to store key/value pairs.
Modules – Provides a modular way of organizing and loading code.
Promises – Used with async operations.
Rest parameters – Replaces the need for using arguments to access functions arguments. Allows you to get to an array representing “the rest of the parameters”.
Set – A collection object that can be used to store a list of data values.
Template Strings – Clean way to build up string values.