从 ES5 到 ES2022,JavaScript 语言的特性得到了不断的扩展和完善。以下是一些主要的特性:
-
ES5
- 严格模式
- JSON 对象
- Array.prototype.forEach()
- Array.prototype.map()
- Array.prototype.filter()
- Array.prototype.reduce()
- Function.prototype.bind()
- Object.create()
- Object.defineProperty()
- Object.defineProperties()
- Object.keys()
- Date.now()
-
ES6
- let 和 const 声明变量
- 箭头函数
- 模板字符串
- 解构赋值
- 默认参数值
- 剩余参数
- 扩展运算符
- for…of 循环
- Map 和 Set 数据结构
- Promise 对象
- 类和继承
-
ES7
- Array.prototype.includes()
- 指数运算符
-
ES8
- async/await 函数:w
-
ES9
- 异步迭代器
-
ES10
- Array.prototype.flat()
- Array.prototype.flatMap()
- String.prototype.trimStart() 和 String.prototype.trimEnd()
-
ES11
- 可选链操作符(Optional Chaining)
- 空值合并操作符(Nullish Coalescing)
-
ES12
- Promise.any()
以上是一些主要的特性,还有很多其他的特性,如果您想了解更多,请参考官方文档。