Ecmascript 6 support on Node.js

情到浓时终转凉″ 提交于 2019-12-03 17:53:00

问题


I've been working with KoaJS for a while, and we can easily use the 'let' keyword and the generators when using the --harmony flag but I couldn't find how much support for does the node v0.11.x provides while using the same.

I tried using the default value argument initialization but couldn't succeed.

Is there any source available which can list the no of features of ECS 6 supported in node v0.11.x using the harmony flag? Or if there is any npm module available for node that might allow me to use the same?

Thanks in advance.


回答1:


With regards to your second question, yes, there is es6-module-loader. For a long list of transpilers, shims, and other tools for using full ES6 features now, see addyosmani's ECMAScript 6 Tools page.

As for native ES6 support in node.js, V8 officially implements "ECMAScript" but AFAIK the V8 project doesn't release a spec of their implementation. However there are some sources of useful information out there. Here's a brief overview of ES6 in node.js v0.11.6.

You may want to determine the version of V8 that your version of node.js uses. See the node.js blog for recent changelog info. It can also be useful to find the version of V8 used in a given Chromium release. The Chrome release notes can be found here. Keep in mind that different flags can be set for the same version of V8. Chromium and node.js both have ways to set flags in V8 related to ES6 support.

Here are two tables that list ES(6) feature support across implementations:

  • http://pointedears.de/scripts/test/es-matrix/
  • http://kangax.github.io/compat-table/es6/

This MDN page lists a set of reference articles for ES6 language features. At the bottom of each one you can see the status of Chrome support for that feature (and using V8 versions determine the support in node.js).

Finally, the V8 issue tracker provides a list of issues related to ES6 features, many of which have been implemented and their issues closed.




回答2:


You can use ~96% of ES6 features in Node.js 6. You can review support for all versions on http://node.green/




回答3:


This does not concern node 0.11, but in the current 5.8.0, you can use --harmony_default_parameter.

It it scheduled to be included by default in v6.0.



来源:https://stackoverflow.com/questions/25249617/ecmascript-6-support-on-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!