天有多云转晴

ECMAScript 新特性记录

最后更新于

1 目录

目录

2 背景

TC39 是一个由各大浏览器厂商、JavaScript 引擎厂商、各大技术社区、各大技术公司、各大高校、各大研究机构等组成的委员会, 负责制定 ECMAScript 标准.

2.1 标准修订和日程安排

The TC39 Process

TC39 打算在每年 7 月向 ECMA 大会提交一份规范以供批准. 以下是制定新规范的大致时间表:

  • 2月1日: 生成候选草案.
  • 2月-3月: 60天免版税退出期.
  • 3月 TC39 会议: 第 4 阶段提案被合并, 最终语义被批准, 新的规范版本从 master 分支出来. 从这时起, 只接受编辑更改.
  • 4月-6月: ECMA CC 和 ECMA GA 审查期.
  • 7月: ECMA 大会批准新标准.

2.2 已完成的提案

Finished Proposals

已完成的提案是已经达到第 4 阶段的提案, 并包含在规范的最新草案中.

3 ECMAScript 2015(ES6)

  • letconst
  • 解构赋值
  • 模板字符串
  • 扩展运算符
  • 箭头函数
  • 函数参数默认值
  • 剩余参数
  • 对象属性简写
  • 对象方法简写

4 ECMAScript 2016(ES7)

  • Array.prototype.includes
    • Array.prototype.includes
    • TypedArray.prototype.includes
  • 指数运算符: **

4.1 Array.prototype.includes

提议 |

4.1.1 Array.prototype.includes

规范 | mdn |

4.1.2 TypedArray.prototype.includes

规范 | mdn |

4.2 指数运算符

提议 | 规范 | mdn |

5 ECMAScript 2017(ES8)

  • Object.values/Object.entries
  • String padding
    • String.prototype.padStart
    • String.prototype.padEnd
  • Object.getOwnPropertyDescriptors
  • Trailing commas in function parameter lists and calls
  • Async Functions
  • Shared Memory and Atomics

5.1 Object.values/Object.entries

5.1.1 Object.values

提议 | 规范 | mdn |

5.1.2 Object.entries

提议 | 规范 | mdn |

5.2 String padding

5.2.1 String.prototype.padStart

提议 | 规范 | mdn |

5.2.2 String.prototype.padEnd

提议 | 规范 | mdn |

5.3 Object.getOwnPropertyDescriptors

提议 | 规范 | mdn |

5.4 Trailing commas in function parameter lists and calls

提议 | 规范 | mdn |

函数参数列表和调用中的尾随逗号

5.5 Async Functions

提议 | 规范 | mdn |

5.6 Shared Memory and Atomics

提议 | 规范 |

共享内存和原子操作

6 ECMAScript 2018(ES9)

  • Lifting template literal restriction
  • s(dotAll) flag for regular expressions
    • 修饰符: s
    • RegExp.prototype.dotAll
  • RegExp named capture groups
  • Rest/Spread Properties
  • RegExp Lookbehind Assertions
    • ?<=
    • ?<!
  • RegExp Unicode Property Escapes
  • Promise.prototype.finally
  • Asynchronous Iteration
    • for await...of
    • async function*

6.1 Lifting template literal restriction

提议 | 规范 | mdn |

解除模板字符串限制(\转义不再报错, 仅在作为标签函数的参数时生效)

6.2 s(dotAll) flag for regular expressions

提议 |

使用 s 修饰符, . 可以匹配任意字符, 包括换行符(\n)

6.2.1 修饰符: s

规范 | mdn |

6.2.2 RegExp.prototype.dotAll

规范 | mdn |

6.3 RegExp named capture groups

提议 | 规范 | mdn |

6.4 Rest/Spread Properties

剩余/扩展属性

6.4.1 Rest Properties

提议 | 规范 | mdn |

6.4.2 Spread Properties

提议 | 规范 | mdn |

6.5 RegExp Lookbehind Assertions

提议 | 规范 | mdn |

6.5.1 ?<=

6.5.2 ?<!

6.6 RegExp Unicode Property Escapes

提议 | 规范 | mdn |

6.7 Promise.prototype.finally

提议 | 规范 | mdn |

6.8 Asynchronous Iteration

提议 | 规范 | mdn |

6.8.1 for await...of

规范 | mdn

6.8.2 Async generator functions

规范 | mdn

7 ECMAScript 2019(ES10)

  • Optional catch binding
  • JSON superset (TBC)
  • Symbol.prototype.description
  • Function.prototype.toString revision
  • Object.fromEntries
  • Well-formed JSON.stringify
  • String.prototype.{trimStart,trimEnd}
    • String.prototype.trimStart
    • String.prototype.trimEnd
  • Array.prototype.{flat,flatMap}
    • Array.prototype.flat
    • Array.prototype.flatMap

7.1 Optional catch binding

提议 | 规范 | mdn |

catch 语句中的参数及括号可以省略

7.2 JSON superset

提议 |

7.3 Symbol.prototype.description

提议 | 规范 | mdn |

7.4 Function.prototype.toString revision

提议 | 规范 | mdn |

7.5 Object.fromEntries

提议 | 规范 | mdn |

7.6 Well-formed JSON.stringify

提议 | 规范 | mdn |

7.7 String.prototype.{trimStart,trimEnd}

提议 |

7.7.1 String.prototype.trimStart

规范 | mdn |

7.7.2 String.prototype.trimEnd

规范 | mdn |

7.8 Array.prototype.{flat,flatMap}

提议 |

7.8.1 Array.prototype.flat

规范 | mdn |

7.8.2 Array.prototype.flatMap

规范 | mdn |

8 ECMAScript 2020(ES11)

  • String.prototype.matchAll
  • import()
  • BigInt
  • Promise.allSettled
  • globalThis
  • for-in mechanics
  • Optional chaining: 可选链运算符
  • Nullish coalescing Operator: 空值合并运算符
  • import.meta

8.1 String.prototype.matchAll

提议 | 规范 | mdn |

8.2 import()

提议 | 规范 | mdn |

8.3 BigInt

提议 | 规范 | mdn |

8.4 Promise.allSettled

提议 | 规范 | mdn |

8.5 globalThis

提议 | 规范 | mdn |

8.6 for-in mechanics

提议 | 规范 | mdn |

8.7 Optional chaining

提议 | 规范 | mdn |

8.8 Nullish coalescing Operator

提议 | 规范 | mdn |

8.9 import.meta

提议 | 规范 | mdn |

9 ECMAScript 2021(ES12)

  • String.prototype.replaceAll
  • Promise.any
  • WeakRefs
  • Logical Assignment Operators: 逻辑赋值操作符
    • &&=
    • ||=
    • ??=
  • Numeric Separators: 数字分隔符

9.1 String.prototype.replaceAll

提议 | 规范 | mdn |

9.2 Promise.any

提议 | 规范 | mdn |

9.3 WeakRefs

提议 | 规范 | mdn |

9.4 Logical Assignment Operators

提议 | 规范 |

9.4.1 &&=

mdn

9.4.2 ||=

mdn

9.4.3 ??=

mdn

9.5 Numeric Separators

提议 | 规范 | mdn |

10 ECMAScript 2022(ES13)

  • Class Fields
    • Field declarations(Public fields)
    • Private fields
  • RegExp Match Indices
    • 修饰符 d
    • RegExp.prototype.hasIndices
  • Top-level await
  • Ergonomic brand checks for private fields
  • .at()
    • String.prototype.at
    • Array.prototype.at
    • TypedArray.prototype.at
  • Accessible Object.prototype.hasOwnProperty: Object.hasOwn
  • Class Static Block
  • Error Cause

10.1 Class Fields

提议 |

10.1.1 Field declarations(Public fields)

规范 | mdn |

10.1.2 Private fields

规范 | mdn |

10.2 RegExp Match Indices

提议 |

10.2.1 修饰符 d

10.2.2 RegExp.prototype.hasIndices

规范 | mdn |

10.3 Top-level await

提议 | 规范 | mdn |

10.4 Ergonomic brand checks for private fields

提议 | 规范 | mdn |

使 in 操作符可以用于检查私有字段

10.5 .at()

提议 |

10.5.1 String.prototype.at

规范 | mdn |

10.5.2 Array.prototype.at

规范 | mdn |

10.5.3 TypedArray.prototype.at

规范 | mdn |

10.6 Accessible Object.prototype.hasOwnProperty: Object.hasOwn

提议 | 规范 | mdn |

10.7 Class Static Block

提议 | 规范 | mdn |

10.8 Error Cause

提议 | 规范 | mdn |

11 ECMAScript 2023(ES14) Coming

  • Array find from last
    • Array.prototype.findLast
    • Array.prototype.findLastIndex
    • TypedArray.prototype.findLast
    • TypedArray.prototype.findLastIndex
  • Hashbang Grammar
  • Symbols as WeakMap keys
  • Change Array by Copy
    • Array.prototype.toReversed
    • Array.prototype.toSorted
    • Array.prototype.toSpliced
    • Array.prototype.with
    • TypedArray.prototype.toReversed
    • TypedArray.prototype.toSorted
    • TypedArray.prototype.with

11.1 Array find from last

提议 |

11.1.1 Array.prototype.findLast

规范 | mdn |

11.1.2 Array.prototype.findLastIndex

规范 | mdn |

11.1.3 TypedArray.prototype.findLast

规范 | mdn |

11.1.4 TypedArray.prototype.findLastIndex

规范 | mdn |

11.2 Hashbang Grammar

提议 | 规范 | mdn |

11.3 Symbols as WeakMap keys

提议 | mdn |

11.4 Change Array by Copy

提议 |

11.4.1 Array.prototype.toReversed

规范 | mdn |

11.4.2 Array.prototype.toSorted

规范 | mdn |

11.4.3 Array.prototype.toSpliced

规范 | mdn |

11.4.4 Array.prototype.with

规范 | mdn |

11.4.5 TypedArray.prototype.toReversed

规范 | mdn |

11.4.6 TypedArray.prototype.toSorted

规范 | mdn |

11.4.7 TypedArray.prototype.with

规范 | mdn |

12 ECMAScript 2024(ES15) Coming

  • Well-Formed Unicode Strings
  • Atomics.waitAsync
  • RegExp v flag with set notation + properties of strings