| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/class | [Back] [Original] |
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. Its been available across browsers since 2017 3.
class , .
class Polygon {
constructor(height, width) {
this.area = height * width;
}
}
console.log(new Polygon(4, 3).area);
// Expected output: 12
class name [extends] {
// class body
}
Polygon , Square Polygon . super() , this .
class Polygon {
constructor(height, width) {
this.name = "Polygon";
this.height = height;
this.width = width;
}
}
class Square extends Polygon {
constructor(length) {
super(length, length);
this.name = "Square";
}
}
: .
class Foo {}
class Foo {} // Uncaught SyntaxError: Identifier 'Foo' has already been declared
.
var Foo = class {};
class Foo {} // Uncaught TypeError: Identifier 'Foo' has already been declared
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-class-definitions |
This page was last modified on 2026 7 15 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |