class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
const p = new Rectangle();
/* -------- クラス式 ---------- */
// 名前なし
let Rectangle = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
console.log(Rectangle.name);
// 出力: "Rectangle"
// 名前つき
let Rectangle = class Rectangle2 {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
console.log(Rectangle.name);
// 出力: "Rectangle2"