这篇翻译不完整。请帮忙从英语翻译这篇文章。
ECMAScript 2015 (6th Edition)是目前ECMAScript语言规范的标准。通常被称为"ES6",在SpiderMonkey 中它规定了JavaScript的实现标准, SpiderMonkey是一个JavaScript引擎,被广泛在火狐浏览器等谋智的众多产品中。
Code-named "ES.next" or "Harmony", the first working draft (based on ECMAScript 5.1) was published on July 12, 2011 as "ES.next". In August 2014, the ECMAScript 6 draft specification was feature frozen and went through a stabilization and bug fixing period. Finally, ECMA-262 Edition 6 got officially approved and published as a standard on June 17, 2015 by the ECMA General Assembly. It will also appear as the international industry standard ISO/IEC 16262:2016.
A PDF and HTML version of the standard can be freely downloaded on ecma-international.org.
A channel for feedback on ECMAScript standards is es-discuss.
Firefox 已经支持的 ECMAScript 6 特性
这里列出的功能已经在Firefox中支持;the version in which support was added is also indicated for each feature.
标准库
Additions to the Array
object
Array
iteration withfor...of
(Firefox 13)Array.from()
(Firefox 32)Array.of()
(Firefox 25)Array.prototype.fill()
(Firefox 31)Array.prototype.find()
,Array.prototype.findIndex()
(Firefox 25)Array.prototype.entries()
,
Array.prototype.keys()
(Firefox 28)Array.prototype.copyWithin()
(Firefox 32)get Array[@@species]
(Firefox 48)
新的 Map 和 Set,以及 WeakMap
和 WeakSet
对象
Map
(Firefox 13)Map
iteration withfor...of
(Firefox 17)Map.prototype.forEach()
(Firefox 25)Map.prototype.entries()
,
Map.prototype.keys()
,
Map.prototype.values()
(Firefox 20)- Constructor argument:
new
(Firefox 37)Map
(null) - Monkey-patched
set()
in Constructor (Firefox 37) get Map[@@species]
(Firefox 41)
Set
(Firefox 13)Set
iteration withfor...of
(Firefox 17)Set.prototype.forEach()
(Firefox 25)Set.prototype.entries()
,
Set.prototype.keys()
,
Set.prototype.values()
(Firefox 24)- Constructor argument:
new
(Firefox 37)Set
(null) - Monkey-patched
add()
in Constructor (Firefox 37) get Set[@@species]
(Firefox 41)
WeakMap
(Firefox 6)WeakMap.clear()
(Firefox 20)- optional iterable argument in
WeakMap
constructor (Firefox 36) - Constructor argument:
new
(Firefox 37)WeakMap
(null) - Monkey-patched
set()
in Constructor (Firefox 37)
WeakSet
(Firefox 34)- Constructor argument:
new
(Firefox 37)WeakSet
(null) - Monkey-patched
add()
in Constructor (Firefox 37)
- Constructor argument:
新的 Math 方法
Math.imul()
(Firefox 20)Math.clz32()
(Firefox 31)Math.fround()
(Firefox 26)Math.log10()
,Math.log2()
,Math.log1p()
,Math.expm1()
,Math.cosh()
,Math.sinh()
,Math.tanh()
,Math.acosh()
,Math.asinh()
,Math.atanh()
,Math.hypot()
,Math.trunc()
,Math.sign()
,Math.cbrt()
(Firefox 25)
Number
对象的补充
Number.isNaN()
(Firefox 16)Number.isFinite()
(Firefox 16)Number.isInteger()
(Firefox 16)Number.parseInt()
(Firefox 25)Number.parseFloat()
(Firefox 25)Number.EPSILON
(Firefox 25)Number.MAX_SAFE_INTEGER
,Number.MIN_SAFE_INTEGER
(Firefox 31)Number.isSafeInteger()
(Firefox 32)
Object
对象的补充
Object.prototype.__proto__
已经被标准化Object.is()
(Firefox 22)Object.setPrototypeOf()
(Firefox 31)Object.assign()
(Firefox 34)Object.getOwnPropertySymbols()
(Firefox 33)
Date
对象的补充
Date.prototype
is an ordinary object (Firefox 41)- generic
Date.prototype.toString
(Firefox 41) Date.prototype[@@toPrimitive]
(Firefox 44)
新的 Promise 对象
Promise
(Firefox 24, 在 Firefox 29 中默认启用)
新的 Reflect 对象
RegExp
对象的补充
RegExp
sticky (y) flag (Firefox 38)RegExp
unicode (u) flag (Firefox 46)- generic
RegExp.prototype.toString
(Firefox 39) RegExp.prototype[@@match]()
(Firefox 49)RegExp.prototype[@@replace]()
(Firefox 49)RegExp.prototype[@@search]()
(Firefox 49)RegExp.prototype[@@split]()
(Firefox 49)get RegExp[@@species]
(Firefox 49)
String
对象的补充
String.fromCodePoint()
(Firefox 29)String.prototype.codePointAt()
(Firefox 29)String.prototype.startsWith()
,String.prototype.endsWith()
(Firefox 17)String.prototype.includes()
(Firefox 40) (formerlyString.prototype.contains()
(Firefox 17))String.prototype.repeat()
(Firefox 24)String.prototype.normalize()
(Firefox 31)String.raw()
(Firefox 34)- \u{XXXXXX} Unicode code point escapes (Firefox 40)
新的 Symbol 对象
Symbol
(Firefox 36)Symbol.iterator
(Firefox 36)Symbol.for()
- global Symbol registry (Firefox 36)Symbol.match
(Firefox 40)Symbol.species
(Firefox 41)Symbol.toPrimitive
(Firefox 44)Symbol.prototype[@@toPrimitive]
(Firefox 44)Symbol.replace
(Firefox 49)Symbol.search
(Firefox 49)Symbol.split
(Firefox 49)Symbol.hasInstance
(Firefox 50)
Typed Arrays
Typed arrays are specified as part of ECMAScript 6 and no longer in their own specification.
ArrayBuffer
get ArrayBuffer[@@species]
(Firefox 48)DataView
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
get %TypedArray%[@@species]
(Firefox 48)
表达式和操作符
- Spread operator for arrays (Firefox 16)
- use
Symbol.iterator
property (Firefox 36)
- use
- Spread operator for function calls (Firefox 27)
- use
Symbol.iterator
property (Firefox 36)
- use
语句
for...of
(Firefox 13)- works in terms of
.iterator()
and.next()
(Firefox 17) - use
"@@iterator"
property (Firefox 27) - use
Symbol.iterator
property (Firefox 36)
- works in terms of
函数
- Rest parameters (Firefox 15)
- Default parameters (Firefox 15)
- Parameters without defaults after default parameters (Firefox 26)
- Destructured parameters with default value assignment (Firefox 41)
- Arrow functions (Firefox 22)
Generator function
(Firefox 26)arguments[@@iterator]
(Firefox 46)
其他特性
- Binary and octal numeric literals (Firefox 25)
- Template strings (Firefox 34)
- Object initializer: shorthand property names (Firefox 33)
- Object initializer: computed property names (Firefox 34)
- Object initializer: shorthand method names (Firefox 34)
和ES6规范不兼容的特性
The following features are (partially) implemented in Firefox, but are not compliant with the specification. There are a couple of possible reasons for this: Firefox's implementation is based on an older draft of the ES6 specification, or Firefox's current implementation is an experimental design added before a similar feature was added to the ES6 specification.
- Legacy iterators and generators (JS 1.7, Firefox 2)
- ES6 iterators and generators implemented in Firefox 26+
- Destructuring assignment (JS 1.7, Firefox 2) (ES6 compliance bug 950547)
const
(JS 1.5, Firefox 1.0) (ES6 compliance bug 950547)let
(JS 1.7, Firefox 2) (ES6 compliance bug 950547)Proxy
(Firefox 18) (ES6 compliance bug 978228)
Features partially supported by Firefox
These features, while part of ECMAScript 6, are only partially implemented in Firefox, and are only available in nightly builds.
New class
syntax
- Basic support (bug 837314)
extends
supportstatic
method definitions
还未支持的 ECMAScript 6 的功能
以下是 Firefox 实现(部分)的功能,但不符合规范。有那么几个能解释这个的原因:这些功能的实现是基于 ES6 规范较早期的草案,或 Firefox 的当前实现是一个实验性的设计,在与这个设计类似的功能加入到 ES6 规范之前。
- Legacy iterators and generators (JS 1.7, Firefox 2)
- Destructuring assignment (JS 1.7, Firefox 2) (ES6 compliance bug 1055984)
const
(JS 1.5, Firefox 1.0) (ES6 compliance bug 950547 implemented in Firefox 51)let
(JS 1.7, Firefox 2) (ES6 compliance bug 950547 implemented in Firefox 51)