为什么我在给子类添加原型方法后无法调用父类原型上的方法
function Person(name, age) {
this.name = name || "person";
this.age = age || 0;
}
Person.prototype = {
LEG_NUM:2,
ARM_NUM:2,
sayHi: function () {
console.log("my name is" + this.name + "my age is " + this.age + "years old");
},
walking: function () {
console.log(this.name + "is walking");
}
}
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 = {
sayHi: function () {
console.log("my name is " + this.name + "my age is " + this.age + "my class is " + this.classname);
},
learn: function (obj) {
console.log(this.name + "is learning..." + obj);
}
}
var leo = new Student("leo", 12, "class 2,grade 3");
leo.walking();
leo.sayHi();
leo.learn("math");
console.log(leo.LEG_NUM);
console.log(leo.ARM_NUM);
去掉子类的原型方法就能用了????