ES6及以后各版本新特性汇总

134 阅读1分钟

ES6及以后各版本新特性汇总

版本特性
ES6 (2015)- let和const声明变量
- 箭头函数
- 模板字符串
- 默认参数
- 展开操作符
- 剩余参数
- 解构赋值
- Promise
- 类
- 模块化(import和export)
- Symbol
- Set和Map
- Proxy和Reflect
- for...of循环
- Iterators和Generators
- Unicode支持增强
ES7 (2016)- Array.prototype.includes
- 指数操作符( ** )
ES8 (2017)- 异步函数(async/await)
- 共享内存和原子操作
- Object.values和Object.entries
- String.prototype.padStart和String.prototype.padEnd
- Object.getOwnPropertyDescriptors
- Rest/Spread属性
ES9 (2018)- 模版字符串限制调整
- Promise.finally
- 异步迭代(for-await-of)
- Rest/Spread属性在对象中的使用
- 正则表达式改进(dotAll模式、命名捕获组等)
ES10 (2019)- Array.prototype.flat和Array.prototype.flatMap
- String.prototype.trimStart和String.prototype.trimEnd
- Object.fromEntries
- 可选的catch绑定
- Symbol.description
- JSON superset
- Function.prototype.toString修订
ES11 (2020)- 可选链操作符(?.)
- 空值合并操作符(??)
- Promise.allSettled
- 国际化功能增强(Intl)
- dynamic import()
- globalThis
- String.prototype.replaceAll
- 逻辑赋值操作符
ES12 (2021)- 逻辑赋值操作符(&&=, ||=, ??=)
- RegExp Match Indices
- Promise.any
- AggregateError
- String.prototype.replaceAll
- 新的类私有方法和字段
ES13 (2022)- 类的公共实例字段和私有实例字段
- RegExp Match Indices 和 groups 属性的改进
- Top-level await
- Array.prototype.at()
- Error Cause
- Object.hasOwn()
ES14(2023)- Array.prototype.toSorted()
-Array.prototype.toReversed()
-Array.prototype.with()
-Array.prototype.findLast()
-Array.prototype.findLastIndex()
-Array.prototype.toSpliced()

参考

proposals/finished-proposals.md at main · tc39/proposals (github.com)