Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2017년 3월.
class 선언은 프로토타입 기반 상속을 사용하여, 주어진 이름의 새로운 클래스를 만듭니다.
클래스 표현을 사용하여 클래스를 정의할 수도 있습니다. 표현식과 달리 선언문으로는 같은 클래스를 다시 선언하면 오류가 발생합니다.
클래스 본문은 엄격 모드에서 실행됩니다. 생성자 속성은 선택 사항입니다..
클래스 선언은 함수 선언과 달리 호이스팅의 대상이 아닙니다.
다음 예제는 우선 Polygon 클래스를 정의하고, Square라는 이름의 새로운 클래스가 Polygon을 상속합니다. 생성자 내부의 super()는 생성자 내에서만, 그리고 this 키워드를 사용하기 전에만 쓸 수 있다는 점을 주의하세요.
경고 : 같은 클래스를 두 번 선언하려고 시도할 때 클래스 선언문으로 같은 클래스를 두 번 선언하면 오류가 발생합니다.
이전에 표현식으로 정의한 경우에도 오류가 발생합니다.
| ECMAScript® 2027 Language Specification # sec-class-definitions |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 2월 11일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.