name이라는 변수가 따로 없어도 클래스 뒤에 붙은게 클래스 이름이다.
클래스에 이름이 없어면 변수 이름으로 한다.
// unnamed
let Rectangle = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
console.log(Rectangle.name);
// 출력: "Rectangle"
// named
let Rectangle = class Rectangle2 {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
console.log(Rectangle.name);
// 출력: "Rectangle2"
댓글 영역