let
声明块级作用域变量let
用在花括号 { }里面
在用 let
声明之前,变量不可用,会报错,而 var
声明之前的变量则返回 undefined
class
更接近传统OOP的写法1
2
3
4
5
6
7
8
9
10
11
12class Cat{
constructor(){
this.name = "cat";
this.color = "black";
}
}
class YellowCat extends Cat{
constructor(){
super();
this.color = 'yellow';
}
}