!Hola,amigos.我有这个小类继承结构
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString() {
return '(' + this.x + ', ' + this.y + ')';
}
}
class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
toString() {
return super.toString() + ' in ' + this.color;
}
}
let newObj = new ColorPoint(25, 8, 'green');
Run Code Online (Sandbox Code Playgroud)
它汇编到这个jsfiddle
我以愚蠢的方式了解它在es6中是如何工作的.但是有人可以解释它在es5中如何工作.以更简单的形式.