As previously mentioned, there’s a great set of new features in ES6. To provide a brief overview of a few of my favourites:
Otherwise known as ‘fat arrows’, the => symbol is a new syntax feature which allows for shorthand function definition. Some good examples include:
const firstNames = fullNames.filter(name => name.firstName);
lexical scoping and constants
The let keyword allows us to define variables we plan to change with lexical scoping in mind – that is, block-scoping (opposed to the traditional function-level scope we receive with var).
The const keyword allows us to define variables in our code that we expect not to change and thus, cannot be changed or mutated. They’re immutable in this sense and provides some robust features to our code.
At a first glance, the Map type looks to be identical to traditional Objects; however, upon further inspection, a number of differences can be spotted.
Firstly, Maps are traditionally iterable – a for loop can iterate through a map. Secondly, you can retrieve the size of a Map easily in comparison to traditional objects. For dynamic objects, maps are ideal when you need to keep track of objects at run-time.
See this link for the current status of ES6 support in all modern browser engines.