为什么我按老师的代码写,却没有输出相应的值,name,age都是undefined呢?求帮助
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>OOP</title>
</head>
<body>
<script type="text/javascript">
function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.hi = function(){
document.write('Hi,my name is '+this.name+",I'm "+age+' years old now'+"<br>");
};
Person.prototype.LEGS_NUM = 2;
Person.prototype.ARMS_NUM = 2;
Person.prototype.walk = function(){
document.write(this.name+" is walking..."+"<br>");
};
function Student(name, age, className){
Person.call(this.name,age);
this.className = className;
}
Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;
Student.prototype.hi = function(){
document.write('Hi,my name is '+this.name+",I'm "+age+' years old now, and from '+this.className+"<br>");
};
Student.prototype.learn = function(subject){
document.write(this.name+' is learning '+subject+' at '+this.className+"<br>");
};
var jack = new Student('Jack',10,'Class 1,Grade 3'+"<br>");
jack.hi();
document.write(jack.LEGS_NUM+"<br>");
jack.walk();
jack.learn('Chinese');
</script>
</body>
</html>