class Father{
constructor(){
this.name = '父亲'
this.age = 33
}
work(){
console.log('我是父类');
}
}
class Children extends Father{
constructor(name,age,play){
super()
this.name = name
}
}
let personZhang = new Children('tony',44,'打游戏')
console.log(personZhang.name);
super
class A{
pA = 123
p(){
return 3
}
}
A.prototype.pA = 123
class B extends A{
constructor(){
super()
console.log(super.p())
console.log(super.pA)
}
}
class A{
constructor(){
this.x = 1
}
print(){
console.log(this.x);
}
}
class B extends A{
constructor(){
super()
this.x = 2
}
fn(){
super.print()
}
}
class A{
constructor(){
this.x = 1
}
}
class B extends A{
constructor(){
super()
this.x = 2
super.x = 3
console.log(super.x);
console.log(this.x);
}
}
class Parent{
static myMethod(msg){
console.log(`static-${msg}`);
}
myMethod(msg){
console.log(`普通-${msg}`);
}
}
class Child extends Parent{
static myMethod(msg){
super.myMethod(msg)
}
myMethod(msg){
super.myMethod(msg)
}
}
class A{
constructor(){
this.x = 1
}
static print(){
console.log(this.x);
}
}
class B extends A{
constructor(){
super()
this.x = 2
}
static fn(){
super.print()
}
}