Node.js 0.12中提供的ECMAScript 6功能 [英] ECMAScript 6 features available in Node.js 0.12
问题描述
一个新的稳定版本的Node.js(0.12)最近登陆了一个升级后的Google v8 JavaScript引擎,这个引擎是v3.28.73。
什么ECMAScript 6功能当前存在于Node.js中,而不使用 - 和谐
标志?
I已经检查了几个声称列出ES 6功能的网站,但所有这些网站似乎已经过时了 - 最突出的是,此表格(更新: 现在更新为当前的Node.js状态为0.12 ),因为几个功能被列为需要 - 和声
标志,而我发现其中一些默认启用(地图,集合,符号等)。 更新:特定于节点的表已经可用
此外,尝试谷歌这个信息纯粹为v8引擎提供了最新的信息 - 目前的v8版本是4.2。* ,这是比Node先进的。 js使用。
我的希望是,这个问题(及其答案)将成为现在可用于Node.js开发人员的ES 6功能的全面总结。 p>
在Node.js中启用了ES 6功能0.12我目前知道:
- 地图,Set / WeakMaps,WeakSets
- 符号
- Object.observe
- 承诺
- 号码
- .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
没有的功能 - 和谐
标志:
- for-of循环
- Map , Set , WeakMap , WeakSet (已指定有问题)
- 符号(已指定有问题)
- 承诺(已经指定有问题)
- 数组方法:
- 对象:
- 。observe()(最初是计划用于ES7 ,但是完全从规格中删除)
- 。is()
- 。setPrototypeOf()
- 。getOwnPropertySymbols()
- .getNotifier()(不是es6,例如这里)
- .apply()和.call()(不是es6,作为Funciton.prototype.call和Function.prototype.apply)
- 数字属性和方法(已经指定的问题)
- 数学方法(很多的)(已经指明了)
- 常量
我认为这些都是我们没有 - 和谐
标志。
功能与 - 和谐
标志:
- 生成器
- 箭头功能(不需要
- harmony_arrow_functions
标志与io.js
相反) - 让变量 - 只在
严格模式
- 二进制和八进制文字
-
字符串方法:
- .contains () (在实际的ES6规范中被
include()
替代) - 。startsWith()
- 。endsWith()
- .codePointAt()
- 。repeat()
- 。normalize()
- Stri ng.fromCodePoint
- .contains () (在实际的ES6规范中被
-
Proxy (
- 和谐代理
标志之后) p>
我想是这样。也许如果我忘了一些东西 - 我稍后会添加到列表中。
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
Features without --harmony
flag:
- "for-of" loop
- Map, Set, WeakMap, WeakSet (already specified in question)
- Symbol (already specified in question)
- Promise (already specified in question)
- Array methods:
- Object:
- .observe() (initially was planned for ES7, but was removed from the spec entirely on November 2, 2015)
- .is()
- .setPrototypeOf()
- .getOwnPropertySymbols()
- .getNotifier() (not es6, example here)
- .apply() and .call() (not es6, same purpose as Funciton.prototype.call and Function.prototype.apply)
- Number properties and methods (already specified in question)
- Math methods (a lot of them) (already specified in question)
- constants
I thinks that's all that we have without --harmony
flag.
Features with --harmony
flag:
- generators
- arrow functions (without need of
--harmony_arrow_functions
flag in contrast toio.js
) - let variables - only in
strict mode
- Binary and octal literals
String methods:
- .contains() (was replaced by
includes()
in actual ES6 specification) - .startsWith()
- .endsWith()
- .codePointAt()
- .repeat()
- .normalize()
- String.fromCodePoint
- .contains() (was replaced by
Proxy (behind the
--harmony-proxies
flag)
I think that's all. Maybe if I forgot something - I'll add it later to the list.
这篇关于Node.js 0.12中提供的ECMAScript 6功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!