The draft ECMAScript 2016 standard is online here and it contains two new features:
- Exponentiation operator
So let’s take a look at the new features
This is a new method for arrays to check if an array contains a value. It works pretty much as you’d expect.
[1, 2, 3, 4].includes(4); // true [1, 2, 3, 4].includes(5); // false
It’s almost the same as using
[1, 2, 3, 4].indexOf(4) >= 0; // true
The difference is that it will find
[NaN].includes(NaN); // true [NaN].indexOf(NaN) >= 0; // false
According to this compatability table it looks like it’s already surprisingly well supported.
The usual suspects are lagging behind but if you’re on an up to date Edge, Chrome or Firefox you should be able to pop open the console and try it out.
The exponentiation operator is a new operator for using exponentials.
2 ** 3; // 8 3 ** 3; // 27
It’s almost the same as
Math.pow(2, 3); // 8
Except that because it’s an operator you can do things like this
var a = 3; a **= 3; // 27
If you’d like to start using it in the browser, you’re probably going to have to wait. Pretty much no-one except Edge or Chrome Canary has implemented it yet.
If you want to use it in your next project, babel has a plugin for transpiling it here .
Why so small?
At first glance ES7 isn’t too exciting. It’s a pretty small release with just 2 vanilla features.
ES6 was a nightmare to get ratified and approved because there were so many changes.
So going forward Technical Committee 39 (TC39) is maintaining a backlog of new language features and doing smaller incremental releases of whichever features are ready. The fact that ES7 is so small proves that TC39 is making more frequent, smaller releases. So now the developer community can get their hands on new features earlier.
How TC39 works
They meet every 2 months and their meeting notes can be found online here . Their meetings look pretty much like you’d imagine. Here’s a picture from last year. You could probably use it as a stock image for ‘Technical Committee’.
You can find the feature backlog [here] ( https://github.com/tc39/ecma262/blob/master/README.md )
Each feature is classified into stages base on it’s maturity:
- Stage 1 – Proposal
- Stage 2 – Draft
- Stage 3 – Candidate
- Stage 4 – Finished
The great thing about this new process is that it makes the upcoming features visible. If you look at the list of current proposals you can see that the Stage 3 features are the most likely to make it into ES8.
The language feature that I’m the most excited about is the Async stuff which will help improve the language level model for writing asynchronous code.