function Person(name,age){ this.name=name; this.age=age; this.getName=function(){ console.log(this.name); } } Person.prototype.sayAge="hehe"; var p = new Person("lucy","21"); console.log(1,p instanceof Person); console.log(2,p.constructor === Person); console.log(3,p.hasOwnProperty('getAge'),p.sayAge); Person.prototype={ getAge:function(){ alert(this.age); } } var d = new Person("lucy","21"); console.log(1,d instanceof Person); console.log(2,d.constructor === Person); console.log(3,d.hasOwnProperty('getAge'),d.sayAge); 如上,不知哪位能给出图形描述此题中原型链指向的情况~~~
添加回答
举报
0/150
提交
取消