ES6: Overview
What is ES6?
ECMAScript 2015 (ES2015, ES6, Harmony) is a major update for ECMAScript standard since 2009. ES6 introduces a lot of new features such as arrow functions, class declaration and native Promise. Most of them are syntactic sugar that not only save us some keystrokes, but also make our code more concise.
ES6 is officially finalised on 17th June 2015. Since it is already finalised, we will see more and more libraries and examples to be written in ES6, so get ready for the change!
You can find the full ECMAScript 2015 specification in PDF and HTML version at ecma-international.org.
New ES6 features
- Arrows and Lexical This
- Classes
- Enhanced Object Literals
- Template Strings
- Destructuring
- Default + Rest + Spread
- Let + Const
- Iterators + for…of
- Generators
- Comprehensions
- Unicode
- Modules
- Map + Set + WeakMap + WeakSet
- Proxies
- Symbols
- Subclassable Built-ins
- Math + Number + String + Object APIs
- Binary and Octal Literals
- Promises
- Reflect API
- Tail Calls
You can have a look at the highlights here.
Use ES6 today
If you are wondering when can you start using the shining features, the answer is now! The browser/runtime support (full list here) at the time of writing is:
- Edge 13–84%
- FF 42–71%
- Chrome 46–63%
- NodeJS 5.0–59%
Yes IE (ok Edge) tops the list by a tremendous 84% compatibility!
That sounds promising but we cannot ignore the users of legacy browsers. Fear not, we can still write in ES6 with the help of compilers. Compilers like Babel and Tranceur transpile ES6 code to its equivalent ES5 (or even ES3) code that legacy browsers understand. So move on and write future-proof codes now!
Objective of this series
It may seem a bit late to write this series as there are already a lot of excellent resources online and offline that cover all aspects of ES6. Nevertheless, my main objectives to writing this ES6 series is:
- to contribute to the adoption of ES6
- to improve my ES6 knowledge and writing skills
I hope this series can help people to learn ES6 in an easy way. This is my first time writing a series, if there is anything I can improve or if there is any mistake in the series, please leave your comment below!
Thank you and stay tuned for the next article in the series next week. See you!