File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
class Rectangle {
4+
constructor(height, width) {
5+
this.height = height;
6+
this.width = width;
7+
}
8+
9+
get area() {
10+
return this.height * this.width;
11+
}
12+
}
13+
14+
class Square extends Rectangle {
15+
constructor(side) {
16+
super(side, side);
17+
}
18+
19+
get side() {
20+
return this.height;
21+
}
22+
}
23+
24+
// Usage
25+
26+
const square = new Square(100);
27+
console.dir({ square });
28+
console.log('square.area:', square.area);
29+
console.log('square.side:', square.side);

0 commit comments

Comments
 (0)