mirror of
https://github.com/swc-project/swc.git
synced 2024-12-19 03:31:45 +03:00
23 lines
400 B
JavaScript
23 lines
400 B
JavaScript
|
class Rectangle {
|
||
|
constructor(height, width) {
|
||
|
this.height = height;
|
||
|
this.width = width;
|
||
|
}
|
||
|
|
||
|
set height(height) { this.height = height; }
|
||
|
|
||
|
set width(width) { this.width = width; }
|
||
|
|
||
|
get area() {
|
||
|
return this.calcArea();
|
||
|
}
|
||
|
|
||
|
calcArea() {
|
||
|
return this.height * this.width;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const square = new Rectangle(10, 10);
|
||
|
|
||
|
console.log(square.area);
|