请老师检查,谢谢
来源:6-8 编程练习
胜己
2020-09-13 18:49:30
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
//补充代码
function Animal(name,num) {
this.name = name;
this.num = num;
this.getInfo = function() {
alert(this.name + ',' + this.num);
}
}
function Cat() {
Animal.call(this,'xm',5);
}
function Dot() {
Animal.apply(this,['xh',10]);
}
var c = new Cat();
var d = new Dot();
c.getInfo();
d.getInfo();
</script>
</body>
</html>
1回答
同学你好,效果是可以的,继续加油,祝学习愉快~