Skip to content

ES6-新增特性一览 ​

1. let/const取代var ​

2. 字符串模板 ​

3. 对象解构 ​

4. 新数据类型 Symbol ​

5. 新数据结构Map/Set/WeakMap/WeakSet ​

6. Proxy、Reflect ​

7. 扩展 ​

  • 字符串填充(padStart 和 padEnd)

  • 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()

8. 异步 ​

  • Promise
    • Promise.prototype.then
    • Promise.prototype.catch
    • Promise.prototype.finallyES9
    • Promise.all()
    • Promise.rece()
  • Iterator
    • Iterator接口
    • for of
  • Generator
    • yield*
  • async/awaitES8

9. Class类 ​

  • class
  • extends
  • decoratorES7

10. Module ​

  • import
  • export
javascript
// export default 方式
import defaultName from 'modules.js';

// export type 方式
import { export1, export2 } from 'modules';
import { export1 as ex1, export2 as ex2 } from 'moduls.js'; // as 关键字
import * as moduleName from 'modules.js';

// 同时引入export default 和export type
import defaultName, { expoprt1, export2 } from 'modules';
import defaultName, * as moduleName from 'modules';

// 引入无输出模块
import 'modules';

参考文档 ​

最近更新