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); 如上,不知哪位能給出圖形描述此題中原型鏈指向的情況~~~
修改原型對(duì)象的問(wèn)題
至尊寶的傳說(shuō)
2018-09-13 05:37:11