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

 

posted @ 2021-11-17 16:41  六月沉  阅读(30)  评论(0)    收藏  举报