1.写法
class User{
constructor(name,password){//构造器
this.name = name;
this.password = password;
}
showName(){
alert(this.name);
}
showPass(){
alert(this.password);
}
}
let user = new User('xk','1234567');
user.showName();
user.shoePass();
2.继承
class VipUser extends User{
constructor(name,password,level){
super(name,password);//执行父类构造器
this.level = level;
}
showLevel(){
alert(this.level);
}
}