How to check if Node.js supports ES6 language feature
“Does Node have built-in Promises?”
Do you have to use a library for Promises or are they supported out of the box? What about string templates or destructuring assignment? What about the version of Node you’re running in production?
Because the speed of change is this fast, it can be hard to try manually to list the features. Hand curated lists lose freshness as soon as a new version of Node is rolled out. Instead of trying to manually list the features, here are two strategies that allow you to determine whether a language feature is implemented in Node.
Way #1, Easy - Compatibility Table
"When were ES6 string templates included in Node?"
Checking compatibility table reveals us they were fully supported from Node.js v4.3.2.
Way #2, Hard - Backtrack V8 version
node -p process.versions.v8.
What features are supported in a V8 version can be determined from Google’s V8 project resources. The V8 team keeps an issue tracker at
bugs.chromium.com. The tracker has dedicated harmony label for upcoming language features. The V8 project also includes a conformance status document tested against Official ECMAScript Conformance Test Suite. The report is updated and versioned along with other V8’s source code. The report can be found in
test/test262 directory for each branch of V8.
"Is destructuring assignment part of Node 5.8.0?"
Node 5.8.0 embeds version 184.108.40.206 of the V8 engine. In the V8 issue tracker, the ticket for for destructuring assignment is #811 Implement destructuring. Then, in the 4.6.85 branch of V8 that used by Node, the ES conformance test tells us that much of #811 tests are skipped or failing.
This tells us that destructuring assignment is not part of Node 5.8.0.
Two ways to check
Language features become available in batches in Node.js and depend on them being implemented in V8 engine first. Manually curated feature lists become quickly outdated. For an evergreen way of checking feature availability you can use a dynamically generated feature list or backtrack the specific version of V8 engine used in Node.