(A)
class Parent {
constructor() {
console.log(`${this.type}::constructor`)
}
}
Parent.prototype.type = 'parent';
class Child extends Parent {
constructor() {
super();
console.log(`${this.type}::constructor`)
}
}
Child.prototype.type = 'child';
const child = new Child();
// → "child::constructor"
// → "child::constructor"(B)
class Parent {
type = 'parent';
constructor() {
console.log(`${this.type}::constructor`)
}
}
class Child extends Parent {
type = 'child';
constructor() {
super();
console.log(`${this.type}::constructor`)
}
}
const child = new Child();
// → "parent::constructor"
// → "child::constructor"NOTICE: As of May 2022, modifications to
.prototypedisable tree-shaking for the entire class.