我试图通过原型继承一个函数,似乎一切都是正确的(根据我),但我得到了错误......任何人帮助我理解这个问题?
功能:
(function($){
var Man = function(info){
this.name = info.name;
this.age = info.age;
this.work = info.work;
}
Man.prototype.tell = function(){
return 'I am Mr.' + this.name;
}
var Dog = function(info){
Man.call(this,info);
}
Dog.prototype = new Man();
var dog1 = new Dog({name:'Dobber',age:3,work:'roming'});
console.log(dog1.tell());
})($);
我得到的错误:
TypeError: info is undefined