javascript的抽象方法的继承

Object.prototype.extend = function(object) {
console.log(this);
console.log(object);
return Object.extend.apply(this, [this, object]);
}

Object.prototype.as = function(){
console.log("a");
}

Object.extend = function(destination, source){
console.log(source); // output:{ add: [Function: add], show: [Function: show] }
console.log(this);
for(property in source){
console.log(property); // Why there is a new property: extend???
destination[property] = source[property];
console.log(destination[property]);
}
console.log(destination);
return destination;
}

/*ShapeBase.prototype = {
show:function(){
console.log("ShapeBase show");
}
initialize:function(){
this.oninit();
}
}*/

function ShapeBase(){
//console.log(this);
this.show = function(){
console.log("ShapeBase show");
};
this.init = function(){
console.log("ShapeBase init");
};
}

function Rect(){}

//子类Rect
Rect.prototype = (new ShapeBase()).extend({
// 添加新方法
add:function(){
console.log("Rect add");
},
// 重写show方法而不改变父类方法
show:function(){
console.log("Rect show");
}
})

那么你的问题是什么呢?

因为
Object.prototype.extend = function(object) {
console.log(this);
console.log(object);
return Object.extend.apply(this, [this, object]);
}
这里给加上了extend