| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Classes/constructor | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since 20163.
constructor class
constructor([arguments]) { ... }
class constructor class constructor SyntaxError
constructor class Square extends Polygon {
constructor(length) {
// class
super(length, length);
// derived class super() this
this.name = "Square";
}
get area() {
return this.height * this.width;
}
set area(value) {
this.area = value;
}
}
base classes
constructor() {}
derived class
constructor(...args) {
super(...args);
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-static-semantics-constructormethod |
This page was last modified on 2025716 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 |