| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Errors/Super_not_called | [Back] [Original] |
Get to know MDN better
JavaScript "must call super constructor before using 'this' in derived class constructor" super() this
ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor (V8-based) ReferenceError: must call super constructor before using 'this' in derived class constructor (Firefox) ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object. (Safari)
ReferenceError
super() new 1 1 this this this this super()
class Base {
constructor() {
this.x = 1;
}
}
class Derived extends Base {
constructor() {
console.log(this.x);
// Base this.x
// ReferenceError: must call super constructor before using 'this' in derived class constructor
}
}
class Base {
constructor() {
this.x = 1;
}
}
class Derived extends Base {
constructor() {
super();
console.log(this.x); // 1
}
}
| Web Proxy Viewer | New URL | Original Page |