function Person(name,age){ this.name = name; this.age = age;}Person.prototype = { sayName : function(){ return "my name is " + this.name; //alert(this.name) }, sayAge : function(){ return "I'am " + this.age + " old"; }}var person = new Person("leo",29);lisi = { name : "lisi" }person.sayName.call(lisi);alert(lisi.sayName()); // lisi.sayName is not a function为什么呢?是我写法的问题吗?第二个问题:person.sayName.call(lisi)跟Person.call(lisi)的区别是什么?我的理解是:后者借用了Person全部的属性跟方法,而前者只是借用了sayName方法而已。(我的理解好像是错的~55555)
添加回答
举报
0/150
提交
取消