js中方法继承
作者:
_Enco_ | 来源:发表于
2017-08-15 11:49 被阅读0次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()
call 和 apply
本文标题:js中方法继承
本文链接:https://www.haomeiwen.com/subject/tevmrxtx.html
网友评论