Featured image of post ECMAScript(ES6)新语法

ECMAScript(ES6)新语法

ECMAScript(ES6)新语法

01.课程介绍-ECMAScript 新功能

02.块的作用域-let

03.恒量-const

04.解构数组-Array Destructuring

05.解构对象-Object Destructuring

06.模版字符串-Template Strings

07.带标签的模版字符串-Tagged Templates

08.判断字符串里是否包含其他字符串

09.默认参数 - Default Parameter Values

10.展开操作符-Spread

11.剩余操作符Rest

12.解构参数 - Destructured Parameters

13.函数的名字-name属性

14.箭头函数-Arrow Fuctions

1
() => { }

15.对象表达式

16.对象属性名

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
const obj = {
  get foo() {},
  set foo(x) {}
};

obj.foo.name
// TypeError: Cannot read property 'name' of undefined

const descriptor = Object.getOwnPropertyDescriptor(obj, 'foo');

descriptor.get.name // "get foo"
descriptor.set.name // "set foo"

17.对比两个值是否相等-Object.is()

1
2
3
4
5
+0 === -0 //true
NaN === NaN // false

Object.is(+0, -0) // false
Object.is(NaN, NaN) // true

18.把对象的值复制到另一个对象里 - Object.assign()

1
2
3
4
5
6
7
const target = { a: 1 };

const source1 = { b: 2 };
const source2 = { c: 3 };

Object.assign(target, source1, source2);
target // {a:1, b:2, c:3}

Object.assign方法实行的是浅拷贝,而不是深拷贝。也就是说,如果源对象某个属性的值是对象,那么目标对象拷贝得到的是这个对象的引用。

1
2
3
4
5
const obj1 = {a: {b: 1}};
const obj2 = Object.assign({}, obj1);

obj1.a.b = 2;
obj2.a.b // 2

19.设置对象的 prototype - Object.setPrototypeOf()
原型

20. __proto__

21.super

22.迭代器 - Iterators

23.生成器 - Generators

24.Classes - 类

25.get 与 set

26.静态方法-staitc

27.继承-extends

28.Set

29.Map

30.Module

模块

31.重命名导出与导入的东西 import export 32.导出与导入默认

export default

p.s. 未完成

Licensed under CC BY-NC-SA 4.0