function Teacher(name,age){
Person.call(this,name,age);
}
function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.getName = function(){
console.log(this.name);
}
Teacher.prototype = Person.prototype;
Teacher1.prototype.constructor = Person;
//Teacher.prototype = new Person();
var t = new Teacher('enco',18);
console.log(t.name);
//console.log(Person.prototype);
//console.log(t.prototype);
t.getName()
网友评论