반응형 super1 JS : Super와 extends를 이용한 클래스 상속 상속 OPP에서 상속은 부모클래스의 특성을 자식클래스가 물려받는 시스템을 말한다. 이를 통해 개발자는 두번 똑같은 내용을 입력할 수고를 덜 수 있다. class Polygon { constructor(height, width) { this.name = 'Polygon'; this.height = height; this.width = width; } } 부모 클래스 Polygon을 선언하였다. constructor(생성자함수) 로 매개변수 height, width를 선언한다. class Square extends Polygon { //extends를 이용해 Polygon을 상속받는다. constructor(length) { // 매개변수 length를 선언한다. super(length, length); /.. 2021. 8. 23. 이전 1 다음 반응형