ES6-新增特性一览
# 1. let/const取代var
# 2. 字符串模板
# 3. 对象解构
# 4. 新数据类型 Symbol
# 5. 新数据结构Map/Set/WeakMap/WeakSet (opens new window)
# 6. Proxy (opens new window)、Reflect (opens new window)
# 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 (opens new window)
- Promise.prototype.then
- Promise.prototype.catch
- Promise.prototype.finally
ES9
- Promise.all()
- Promise.rece()
- Iterator (opens new window)
- Iterator接口
- for of
- Generator (opens new window)
- yield*
- async/await
ES8
# 9. Class类
- class
- extends
- decorator
ES7
# 10. Module
- import
- export
// 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';
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15