| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/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 ..
Class declaration .
, class expression. class expression, class declaration , .
class name [extends] {
//
}
class expression, class declaration . .
Polygon, Square. , 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 declaration . js class Foo {}; class Foo {}; // Uncaught TypeError: Identifier 'Foo' has already been declared , class declaration.
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 11 . 2024 . 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 |