JavaScriptのクラス定義は、C++やJavaにそっくり

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Classes

class Rectangle {
 constructor(height, width) {
  this.height = height;
  this.width = width;
 }

 // ゲッター
 get area() {
  return this.calcArea();
 }

 // メソッド
 calcArea() {
  return this.height * this.width;
 }
}

const square = new Rectangle(10, 10);

console.log(square.area); // 100