ES6 class inheritance
JavaScript
class Rectangle extends Again {
constructor(length, width) {
this.length = length;
this.width = width;
}
getArea() {
return this.length * this.width;
}
}
class Square extends Rectangle {
constructor(length) {
super(length, length);
}
}
class Again extends Square {
constructor(length) {
super(length, length);
}
}
var square = new Again(3);
console.log(square.getArea());
console.log(square instanceof Square);
console.log(square instanceof Rectangle);