❤ ES6-22 Class 的基本语法
类的由来
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.toString = function () {
return '(' + this.x + ', ' + this.y + ')';
};
var p = new Point(1, 2);
Point.prototype.constructor === Point // true
constructor() 方法
类的实例
实例属性的新写法
取值函数(getter)和存值函数(setter)
属性表达式
Class 表达式
const MyClass = class { /* ... */ };