How can I use ES7 (ECMAScript 2016) in nodejs? How can I use it in production?
And in which version of node, I don't need using any module for doing that?
Any help is appreciated.
The exponentiation is the last ES7 feature that was added to Node so if you want to use all ES7 features with no flags then you need at least Node 7.0. If you can use the --harmony flag then you can use at least Node 6.5. The 6. x version is LTS (Long Term Support) so you may want to prefer it over 7.
Introducing the new features that ECMAScript 2016 (ES7) adds to JavaScript. Since ECMAScript 2015 (also known as ES6) was released, it has introduced a huge set of new features. They include arrow functions, sets, maps, classes and destructuring, and much more.
ES7 introduces a new mathematical operator called exponentiation operator. This operator is similar to using Math.pow() method. Exponentiation operator is represented by a double asterisk **. The operator can be used only with numeric values. The syntax for using the exponentiation operator is given below −
Note: This question was explicitly about ES2016 (ES7). See updates below for ES2017 (ES8).
The ES7 had only two main features:
Array.prototype.includes
**
(the exponentiation operator)See on Mozilla Development Network for more info:
According to node.green those are available in Node since, respectively:
See:
The exponentiation is the last ES7 feature that was added to Node so if you want to use all ES7 features with no flags then you need at least Node 7.0. If you can use the --harmony
flag then you can use at least Node 6.5.
The 6.x version is LTS (Long Term Support) so you may want to prefer it over 7.x but you'll need the flag to use the ES7 features.
At the time of this writing the current versions of Node are:
The v8.0 LTS will be released shortly - currently you can use the nightly builds of Node 8.0.
For more info on the release schedule - see:
For other versions to download - see:
Answering the question from the comments, async/await is a feature of ES2017 (ES8), not ES2016 (ES7) as this question was about. See:
- Specification: ECMAScript Latest Draft (ECMA-262) The definition of 'async function' in that specification.
- Status: Draft
- Comment: Initial definition in ES2017.
You can use async/await in:
--harmony
flagFor more info see:
In places where you don't have native support for async
and await
you can use Babel:
or with a slightly different syntax a generator based approach like in co
or Bluebird coroutines:
See those answers for more info:
They include more info about the compatibility and possible workarounds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With