JS的继承


function People(name){
this.name = name;
}
People.prototype.showName=function(){
console.log(this.name);
}
function Student(){
}
Student.prototype=new People("zhangsan");
Student.prototype.study =function(){
console.log("学习");
}
var stu = new Student();
stu.study();
stu.showName();
原型链的最终指向是object object的指向是Null

浙公网安备 33010602011771号