一、ECMAScript6引入了一套新的关键字用来实现class。
    1、这些新的关键字包括class、constructor、static、extends和super

    1. "use strict";
    2. class Polygon {
    3. constructor(height, width) {
    4. this.height = height;
    5. this.width = width;
    6. }
    7. }
    8. class Square extends Polygon {
    9. constructor(sideLength) {
    10. super(sideLength, sideLength);
    11. }
    12. get area() {
    13. return this.height * this.width;
    14. }
    15. set sideLength(newLength) {
    16. this.height = newLength;
    17. this.width = newLength;
    18. }
    19. }
    20. var square = new Square(2);

    待整理:见见:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes