ECMAScript 2015(ES6)及以后版本
🌐 ECMAScript 2015 (ES6) and beyond
Node.js 是基于现代版本的 V8 构建的。通过保持与该引擎最新版本的同步,我们确保及时将 JavaScript ECMA-262 规范 的新特性带给 Node.js 开发者,同时持续提升性能和稳定性。
🌐 Node.js is built against modern versions of V8. By keeping up-to-date with the latest releases of this engine, we ensure new features from the JavaScript ECMA-262 specification are brought to Node.js developers in a timely manner, as well as continued performance and stability improvements.
所有 ECMAScript 2015 (ES6) 的特性被分为三个组:已发布、已分阶段和进行中特性:
🌐 All ECMAScript 2015 (ES6) features are split into three groups for shipping, staged, and in progress features:
- 所有 V8 认为稳定的运输功能在 Node.js 上默认 开启,并且 不需要任何运行时标志。
- 阶段性功能,指那些几乎完成但 V8 团队认为不稳定的功能,需要使用运行时标志:
--harmony。 - 进行中 的功能可以通过各自的 harmony 标志单独激活,但除非用于测试,否则强烈不建议这样做。注意:这些标志由 V8 提供,可能会在没有任何弃用通知的情况下发生变化。
默认情况下,哪些特性随哪个 Node.js 版本一起发布?
🌐 Which features ship with which Node.js version by default?
网站 node.green 提供了基于 kangax 的兼容性表的各版本 Node.js 对 ECMAScript 特性的支持情况的优秀概览。
🌐 The website node.green provides an excellent overview over supported ECMAScript features in various versions of Node.js, based on kangax's compat-table.
哪些功能正在开发中?
🌐 Which features are in progress?
V8 引擎的新功能正在不断添加。一般来说,预计这些功能会出现在未来的 Node.js 版本中,尽管具体时间尚不确定。
🌐 New features are constantly being added to the V8 engine. Generally speaking, expect them to land on a future Node.js release, although timing is unknown.
你可以通过在 --v8-options 参数中进行 grep 来列出每个 Node.js 版本中所有 正在进行中的 功能。请注意,这些是 V8 的不完整且可能存在问题的功能,因此请自行承担风险使用:
🌐 You may list all the in progress features available on each Node.js release by grepping through the --v8-options argument. Please note that these are incomplete and possibly broken features of V8, so use them at your own risk:
node --v8-options | grep "in progress"
我已经设置好了基础设施以使用 --harmony 标志。我应该移除它吗?
🌐 I have my infrastructure set up to leverage the --harmony flag. Should I remove it?
Node.js 上 --harmony 标志目前的行为仅启用分阶段功能。毕竟,它现在是 --es_staging 的同义词。如上所述,这些是已经完成但尚未被认为稳定的功能。如果你想安全起见,尤其是在生产环境中,建议在默认随 V8 发布之前移除此运行时标志,而因此也会影响 Node.js。如果你继续启用此标志,则应准备好在 V8 为更严格遵循标准而更改语义时,后续 Node.js 升级可能会破坏你的代码。
🌐 The current behavior of the --harmony flag on Node.js is to enable staged features only. After all, it is now a synonym of --es_staging. As mentioned above, these are completed features that have not been considered stable yet. If you want to play safe, especially on production environments, consider removing this runtime flag until it ships by default on V8 and, consequently, on Node.js. If you keep this enabled, you should be prepared for further Node.js upgrades to break your code if V8 changes their semantics to more closely follow the standard.
如何查找特定版本的 Node.js 搭载的是哪个版本的 V8?
🌐 How do I find which version of V8 ships with a particular version of Node.js?
Node.js 提供了一种通过 process 全局对象列出随特定二进制文件一起提供的所有依赖及其相应版本的简单方法。对于 V8 引擎,在终端中输入以下内容以获取其版本:
🌐 Node.js provides a simple way to list all dependencies and respective versions that ship with a specific binary through the process global object. In case of the V8 engine, type the following in your terminal to retrieve its version:
node -p process.versions.v8