javascript Node.js 上的 Ecmascript 6 支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25249617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ecmascript 6 support on Node.js
提问by I_Debug_Everything
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.
我使用 KoaJS 已经有一段时间了,我们可以在使用 --harmony 标志时轻松使用 'let' 关键字和生成器,但我找不到节点 v0.11.x 提供了多少支持同时使用相同。
I tried using the default value argument initializationbut 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?
是否有任何可用的来源可以使用和声标志列出节点 v0.11.x 中支持的 ECS 6 的功能数量?或者,是否有任何可用于节点的 npm 模块可能允许我使用相同的模块?
Thanks in advance.
提前致谢。
回答by Andrew
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 Toolspage.
关于你的第二个问题,是的,有es6-module-loader。有关现在使用完整 ES6 功能的转译器、垫片和其他工具的一长串列表,请参阅addyosmani 的ECMAScript 6 工具页面。
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.
至于 node.js 中的原生 ES6 支持,V8 正式实现了“ECMAScript”,但 AFAIK V8 项目没有发布它们的实现规范。然而,有一些有用的信息来源。这是node.js v0.11.6 中 ES6的简要概述。
You may want to determine the version of V8 that your version of node.js uses. See the node.js blogfor 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.
您可能想要确定您的 node.js 版本使用的 V8 版本。有关最近的更改日志信息,请参阅node.js 博客。查找给定 Chromium 版本中使用的 V8 版本也很有用。可以在此处找到 Chrome 发行说明。请记住,可以为相同版本的 V8 设置不同的标志。Chromium 和 node.js 都可以在 V8 中设置与 ES6 支持相关的标志。
Here are two tables that list ES(6) feature support across implementations:
以下是两个表格,列出了跨实现的 ES(6) 功能支持:
This MDN pagelists 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).
这个 MDN 页面列出了一组 ES6 语言特性的参考文章。在每一个的底部,你可以看到 Chrome 对该功能的支持状态(使用 V8 版本决定了 node.js 中的支持)。
Finally, the V8 issue trackerprovides a list of issues related to ES6 features, many of which have been implemented and their issues closed.
最后,V8 问题跟踪器提供了与 ES6 特性相关的问题列表,其中许多已经实现并且它们的问题已经解决。
回答by analytik
You can use ~96% of ES6 features in Node.js 6. You can review support for all versions on http://node.green/
您可以在 Node.js 6 中使用约 96% 的 ES6 功能。您可以在http://node.green/查看对所有版本的支持
回答by serv-inc
This does not concern node 0.11, but in the current 5.8.0, you can use --harmony_default_parameter
.
这与节点 0.11 无关,但在当前的 5.8.0 中,您可以使用--harmony_default_parameter
.