在这看:https://github.com/tc39/proposals/blob/master/finished-proposals.md
JavaScript 语言是 ECMAScript 语法标准的一种规范。所以 JavaScript 的最新特性都是遵循 ECMAScript 的新版本标准来实现的。我们谈论 JavaScript 新特性时,其实就是在谈论 ECMAScript 的新特性或即将成为 ECMAScript 标准的提议(proposal)。
TC39ECMAScript 标准全部由 TC39 (39号技术委员会)制定。其工作内容均可在 github 上查看 (https://github.com/tc39)。ES6发布后,TC39采取每年一次小幅更新标准的方式发布新特性。新特性需要经过4个阶段(stage-1 ~ 4),最后才会作为正式标准发布。其中任新特性在何一个阶段都可能被踢出,失去成为正式标准的机会(流程说明:https://tc39.es/process-document/)。
ES2015(ES6)标准后新增的特性在TC39项目下是公开的: https://github.com/tc39/ecma262#current-proposals
其中进入 finished 阶段的特性,即为 ECMAScript 已发布/即将发布版本的特性。继 ES2015(ES6)以后新增的正式版标准都在这里(不多,对吧)
特性 | 计划发布年份 | 说明 |
---|---|---|
Array.prototype.includes |
2016 | 以前用 arr.indexOf(el) != -1 , 现在用 arr.includes(el) |
Exponentiation operator | 2016 | 幂运算符,m ** n 表示数字m的n次幂 |
Object.values /Object.entries |
2017 | 获取对象的值/键值对,并以数组形式返回 |
String padding | 2017 | 原生支持字符串补全、trim操作了 |
Object.getOwnPropertyDescriptors |
2017 | 获取对象的属性描述(Descriptor) |
Trailing commas in function parameter lists and calls | 2017 | 方法参数后面可以多加一个逗号,function(a, ){/* ...*/} 此处逗号是合法的 |
Async functions | 2017 | async/await语法 |
Shared memory and atomics | 2017 | 多线程编程时的共享内存方法,Atomics/SharedArrayBuffer |
Lifting template literal restriction | 2018 | 模板字符串做方法参数的时候不转义 |
s (dotAll ) flag for regular expressions |
2018 | 正则表达式 s 标记 |
RegExp named capture groups | 2018 | 正则表达式支持声明匹配名称 |
RegExp Lookbehind Assertions | 2018 | 正则表达式后向断言 |
RegExp Unicode Property Escapes | 2018 | 正则表达式 unicode 字符 |
Promise.prototype.finally |
2018 | Promise 支持 finally 方法了 |
Asynchronous Iteration | 2018 | 迭代的时候可以写异步方法了 |
Optional catch binding |
2019 | try 的时候 catcth 可以不用写参数了 |
JSON superset | 2019 | JSON格式支持U+2028 和U+2029 两个字符了 |
Symbol.prototype.description |
2019 | Symbol对象的description属性能返回描述了 |
Function.prototype.toString revision |
2019 | 函数的字符化表示优化 |
Object.fromEntries |
2019 | 数组转JSON,Object.entities 的互反方法 |
Well-formed JSON.stringify |
2019 | 避免JSON字符串化的时候错误字符转义 |
String.prototype.{trimStart,trimEnd} |
2019 | 字符串支持 trimStart 和 trimEnd 方法了 |
Array.prototype.{flat,flatMap} |
2019 | 把多维数字抹平成一维数组 |
String.prototype.matchAll |
2020 | 将所有匹配结果用迭代器方式返回 |
import() |
2020 | import之后直接当方法用: import('console').log('hi~') |
BigInt |
2020 | 超大整数 |
Promise.allSettled |
2020 | 所有Promise完成的结果,不管成功还是失败 |
globalThis |
2020 | 统一全局对象名称,不用各种判断兼容了 |
for-in mechanics |
2020 | for...in 循环时候的输出顺序 |
Optional Chaining | 2020 | 可选链式调用:a?.b?.c?.d //=> null |
Nullish coalescing Operator | 2020 | 新的凝聚语法, '' ?? 1 //=> '' |
import.meta |
2020 | 模块自身的元信息 |
String.prototype.replaceAll |
2021 | 字符串全部替换 |
Promise.any |
2021 | 多个Promise 中任意成功一个 |
WeakRefs | 2021 | 弱引用,消耗低但随时会被回收 |
Logical Assignment Operators | 2021 | 条件赋值语法, a &&= b, a ??= b |
Numeric separators | 2021 | 清晰的标记出数字位数 1_000_000 和 1000000是相同的 |
截止 2020-11-07, 这些都是 finished 阶段的特性,其他升级中的特性也不乏种子选手,比如:私有变量 ( #号)语法,顶层 await 语法等。
网友评论