一、ECMAScript6引入了一套新的关键字用来实现class。
1、这些新的关键字包括class、constructor、static、extends和super
"use strict";
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
class Square extends Polygon {
constructor(sideLength) {
super(sideLength, sideLength);
}
get area() {
return this.height * this.width;
}
set sideLength(newLength) {
this.height = newLength;
this.width = newLength;
}
}
var square = new Square(2);
待整理:见见:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes