11.17

原型

 //原型链
        //Student.prototype
        //console.dir(stu.__proto__===Student.prototype)

 

        1.//console.dir(Student.prototype.__proto__===people.prototype)//Student.prototype=now people
        //console.dir(stu.__proto__.__proto__===people.prototype)//原型链
        //console.dir(people.__proto__.__proto__)
        console.dir(stu.__proto__.__proto__.__proto__.__proto__)
        //console.dir(stu.__proto__.__proto__.__proto__)
        // Student.prototype
        // people.prototype
        // Object.prototype
        // null
 
 
2.
 function people(name){//1
            this.name=name;
        }
        people.prototype.showName=function(){
            console.log(this.name);
        }
        function Student(){//2

        }
        Student.prototype=new people("zhanpeng");//Student.prototype赋值成new people

        Student.prototype.study=function(){
            console.log("学习");

        }
        var stu=new Student();//找出特定的学生
        // stu.study();
        // stu.showName();

 

posted @ 2021-11-17 17:34  詹小生  阅读(26)  评论(0)    收藏  举报