ES6-新增特性一览
# # ES6-新增特性一览
ecma-263 (opens new window) (opens new window)是ES6规范的官网文档,该文档是英文版,而且里面洋洋洒洒写了每个特性的实现步骤,容易看晕。这里推荐@阮一峰老师的ECMAScript 6 入门 (opens new window) (opens new window)和es6features (opens new window) (opens new window)项目,以下每个特性详细案例描述也是外链该项目内容。
以下默认陈述的是ES6标准,部分标注ES7、ES8标准是为了表明其最终发布时间(严谨)。其实大部分在2015年6月(ES6发布时间)都进入了草案阶段(Stage 2),故在babel等转译工具下,都可以使用这些特性在前端工程项目中。
# # 1. let/const取代var (opens new window) (opens new window)
# # 2. 字符串模板 (opens new window) (opens new window)
# # 3. 对象解构 (opens new window) (opens new window)
- Destructuring
- enhanced object literals({foo} === {foo:foo})
# # 4. 新数据类型Symbol (opens new window) (opens new window)
# # 5. 新数据结构Map/Set/WeakMap/WeakSet (opens new window) (opens new window)
# # 6. Proxy (opens new window) (opens new window)、Reflect
# # 7. 扩展
- Array
- Array.from()
- Array.of()
- Array.copyWithin()
- Array.find()
- Array.findIndex()
- Array.fill()
- Array.includes()
ES7
- Object
- Object.keys()
- Object.values()
ES8
- Object.entries()
ES8
- Object.assign()
- Object. is()
- Function
- default
- arraw function (opens new window) (opens new window)
- ...rest运算符
- Number
- Number.isNuN()
- Number.isFinite()
- Number.parseInt()
- Number.parseFloat()
- Number.isInteger()
- Number.isSafeInteger()
- Math
- Math.max(x, y)
- Math.trunc(x)
- Math.sign(x)
- Math.acosh(x)
- Math.asinh(x)
- Math.atanh(x);
- Math.cbrt(x)
- Math.clz32(x)
- Math.cosh(x)
- Math.expm1(x)
- Math.fround(x)
- Math.hypot(...values)
- Math.imul(x, y)
- Math.log1p(x)
- Math.log10(x)
- Math.log2(x)
- Math.tanh(x)
# # 8. 异步
- Promise (opens new window) (opens new window)
- Promise.prototype.then
- Promise.prototype.catch
- Promise.prototype.finally
ES9
- Promise.all()
- Promise.rece()
- Iterator (opens new window) (opens new window)
- Iterator接口
- for of
- Generator (opens new window) (opens new window)
- yield*
- async/await
ES8
# # 9. Class类 (opens new window) (opens new window)
- class
- extends
- decorator
ES7
# # 10. Module (opens new window) (opens new window)
- import
- export
# # 参考文档
编辑 (opens new window)