ECMAScript 6 features available in Node.js 0.12

Javascriptnode.jsV8Ecmascript 6

Javascript Problem Overview


A new stable release of Node.js (0.12) has landed recently with an upgraded Google's v8 JavaScript engine, v3.28.73.

What ECMAScript 6 features are currently present in Node.js, without using the --harmony flag?

I have checked several sites claiming to list the ES 6 features but all of them seem out of date - most prominently, this table (Update: now updated with current Node.js status as of 0.12), because several of the features are listed as requiring the --harmony flag while I found some of them being enabled by default (Maps, Sets, Symbols, to name a few). Update: Node specific tables have since been made available

Also, trying to google this information purely for the v8 engine gives too up-to-date information - current v8 release is 4.2.*, which is quite ahead of what Node.js uses.

My hopes are that this question (and its answers) will become a comprehensive summary on what ES 6 features are now available to Node.js developers.

ES 6 features enabled in Node.js 0.12 I currently know of:

  • Maps, Sets / WeakMaps, WeakSets

  • Symbols

  • Object.observe

  • Promises

  • Number

    • .isInteger
    • .isSafeInteger
    • .isNaN
    • .EPSILON
    • .MIN_SAFE_INTEGER
    • .MAX_SAFE_INTEGER
  • Math

    • .clz32
    • .imul
    • .sign
    • .log10
    • .log2
    • .log1p
    • .expm1
    • .cosh
    • .sinh
    • .tanh
    • .acosh
    • .asinh
    • .atanh
    • .trunc
    • .fround
    • .cbrt
    • .hypot

Javascript Solutions


Solution 1 - Javascript

Features without --harmony flag:

I thinks that's all that we have without --harmony flag.

Features with --harmony flag:

  • Proxy (behind the --harmony-proxies flag)

I think that's all. Maybe if I forgot something - I'll add it later to the list.

Solution 2 - Javascript

ES6 features trickle down to Node in phases. Node uses Google's V8 as the JavaScript engine. A feature being supported in Node means it first has to be implemented in V8 and then Node team has to incorporate it in Node.js.

The team at Google releases a new version of V8 roughly every six weeks, and then it's up to the Node team to take it into use.

Manually curated lists of language features are nice but can become outdated quickly. Node 0.12 is not that in flux anymore, but typically manually curated list becomse obsolete as soon as a new version of Node is rolled out.

Here are two alternate ways to check what features a Node version supports, without relying on a static list. For further reading and more detailed examples of using these, you can check "How to check if Node.js supports ES 6 language feature"

#1 Easy - compatibility table

A dynamically generated list that relies on small tests to confirm the presence of a language feature stays better up to date. One such popular list is kangax.github.io/compat-table/es6/. We are interested only in Node features, so you can use

http://node.green

that leverages the same data as the kangax site.

#2 Hard - backtrack V8 version

Node uses V8 engine, so determining which version of V8 is included in Node tells us what ES6 language features are supported. You can find out which version of V8 was bundled in Node with node -p process.versions.v8.

$ node -p process.versions.v8
4.6.85.31

Then using Google's V8 project resources you can find which features are implemented in each version. The V8 project keeps an issue tracker where you can find ES6+beyond features marked with the harmony label.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobert RossmannView Question on Stackoverflow
Solution 1 - JavascriptalexpodsView Answer on Stackoverflow
Solution 2 - JavascriptpspiView Answer on Stackoverflow