/*
1. 通过Class定义类
2. 在类中通过constructor定义构造方法
3. 通过new来创建类的实例
4. 通过extends来实现类的继承
*/
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString() {
return this.x + this.y;
}
}
var point = new Point(2,3);
console.log(point.toString());
/*
class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
toString() {
return this.color + ' ' + super();
}
}
var colorPoint = new Color(3, 4, 'red');
console.log(colorPoint.toString());
*/