我有一个像这样定义的抽象对象......
var abs = module.exports = function abs(val){
if(!(this instanceof abs)){
return new abs(val);
}
abs.prototype.getName = function getName(){
return val.name;
}
}
和一个我想从它继承的具体类,定义如下......
var concrete = module.exports = function concrete(val){
var abs = require('./abs');
if(!(this instanceof concrete)){
return new concrete(val);
}
concrete.prototype = Object.create(abs.prototype);
}
当我写...
var anObject { name : "John" };
var concreteObject = new concrete(anObject);
concrete.getName();
我收到以下错误..
TypeError: Object #<conrete> has no method 'getName'
我究竟做错了什么?