<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
class Person {
constructor(name) {
this.name = name;
}
speak(){
// 这个this=====================
console.log(this)
console.log('speak')
}
}
class Programmer extends Person{
constructor(name,sex){
super(name);
this.sex = sex;
}
speak(){
super.speak()
console.log('zz')
}
}
const zs = new Programmer('zs', 'male');
zs.speak();
</script>
</body>
</html>
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星