代码图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ffc6746648c2890d983413fab2c5e511.png)
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>03_组合继承</title>
</head>
<body>
<script type="text/javascript">
function Person(name,age){
this.name = name
this.age = age
}
Person.prototype.sayName = function(){
console.log(this.name);
}
function Student(name,age,num){
Person.call(this,name,age)
this.num = num
}
Student.prototype = new Person()
Student.prototype.constructor = Student
Student.prototype.sayNum = function(){
console.log(this.num);
}
var per = new Student('Alice',20,'20202118')
per.sayName()
per.sayNum()
</script>
</body>
</html>